From 26fa8670eddf64929c9c17c87e07506f2e1dc2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Fern=C3=A1ndez=20de=20Alba?= Date: Tue, 11 Apr 2023 17:46:46 +0200 Subject: [PATCH] docs: improve creating view documentation (#4636) (#4679) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roger Boixader Güell Co-authored-by: Steve Piercy --- docs/source/recipes/creating-views.md | 77 ++++++++++++--------------- news/4636.documentation | 1 + 2 files changed, 36 insertions(+), 42 deletions(-) create mode 100644 news/4636.documentation diff --git a/docs/source/recipes/creating-views.md b/docs/source/recipes/creating-views.md index a087fa1201..39e51b9e8a 100644 --- a/docs/source/recipes/creating-views.md +++ b/docs/source/recipes/creating-views.md @@ -142,13 +142,18 @@ called `layoutViews` which registers all the layout views. We will add the `full ```js import { FullView } from './components'; -export const views = { - ...defaultViews, - layoutViews: { - ...defaultViews.layoutViews, - full_view: FullView, - }, -}; +export default function applyConfig(config) { + const defaultViews = config.views + // Add here your project's configuration here by modifying `config` accordingly + config.views = { + ...defaultViews, + layoutViews: { + ...defaultViewslayoutViews, + full_view: FullView, + }, + }; + return config; +} ``` ## Registering a new view called Album View @@ -290,45 +295,33 @@ And in `config.js`: * Add your config changes here. * @module config * @example - * export const settings = { - * ...defaultSettings, - * port: 4300, - * listBlockTypes: { - * ...defaultSettings.listBlockTypes, - * 'my-list-item', - * } + * export default function applyConfig(config) { + * config.settings = { + * ...config.settings, + * port: 4300, + * listBlockTypes: { + * ...config.settings.listBlockTypes, + * 'my-list-item', + * } * } */ -import { - settings as defaultSettings, - views as defaultViews, - widgets as defaultWidgets, - blocks as defaultBlocks, -} from '@plone/volto/config'; - +// All your imports required for the config here BEFORE this line +import '@plone/volto/config'; import { AlbumView, FullView } from './components'; -export const settings = { - ...defaultSettings, -}; - -export const views = { - ...defaultViews, - layoutViews: { - ...defaultViews.layoutViews, - album_view: AlbumView, - full_view: FullView, - }, -}; - -export const widgets = { - ...defaultWidgets, -}; - -export const blocks = { - ...defaultBlocks, -}; +export default function applyConfig(config) { + const defaultViews = config.views + // Add here your project's configuration here by modifying `config` accordingly + config.views = { + ...defaultViews, + layoutViews: { + ...defaultViews.layoutViews, + album_view: AlbumView, + full_view: FullView, + }, + }; + return config; +} -export default SummaryView; ``` diff --git a/news/4636.documentation b/news/4636.documentation new file mode 100644 index 0000000000..e0b90b54be --- /dev/null +++ b/news/4636.documentation @@ -0,0 +1 @@ +Improve creating views documentation page. @rboixaderg \ No newline at end of file