Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve creating view documentation #4636

Merged
merged 4 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 35 additions & 42 deletions docs/source/recipes/creating-views.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
```
1 change: 1 addition & 0 deletions news/4636.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve creating views documentation page. @rboixaderg