Skip to content

Commit

Permalink
Add label_singular to collection config
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Duarte committed Feb 6, 2018
1 parent e9ec6de commit d7ca84a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ media_folder: "assets/uploads"

collections: # A list of collections the CMS should be able to edit
- name: "posts" # Used in routes, ie.: /admin/collections/:slug/edit
label: "Post" # Used in the UI, ie.: "New Post"
label: "Posts" # Used in the UI
label_singular: "Post" # USed in the UI, ie: "New Post"
description: >
The description is a great place for tone setting, high level information, and editing
guidelines that are specific to a collection.
Expand All @@ -22,7 +23,7 @@ collections: # A list of collections the CMS should be able to edit
- {label: "SEO Description", name: "description", widget: "text"}

- name: "faq" # Used in routes, ie.: /admin/collections/:slug/edit
label: "FAQ" # Used in the UI, ie.: "New Post"
label: "FAQ" # Used in the UI
folder: "_faqs"
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
Expand Down
2 changes: 1 addition & 1 deletion src/components/App/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default class Header extends React.Component {
collections.filter(collection => collection.get('create')).toList().map(collection =>
<DropdownItem
key={collection.get("name")}
label={collection.get("label")}
label={collection.get("label_singular") || collection.get("label")}
onClick={() => this.handleCreatePostClick(collection.get('name'))}
/>
)
Expand Down
1 change: 1 addition & 0 deletions src/components/Collection/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Collection extends React.Component {
? null
: <CollectionTop
collectionLabel={collection.get('label')}
collectionLabelSingular={collection.get('label_singular')}
collectionDescription={collection.get('description')}
newEntryUrl={newEntryUrl}
viewStyle={this.state.viewStyle}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Collection/CollectionTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { VIEW_STYLE_LIST, VIEW_STYLE_GRID } from 'Constants/collectionViews';

const CollectionTop = ({
collectionLabel,
collectionLabelSingular,
collectionDescription,
viewStyle,
onChangeViewStyle,
Expand All @@ -19,7 +20,7 @@ const CollectionTop = ({
{
newEntryUrl
? <Link className="nc-collectionPage-topNewButton" to={newEntryUrl}>
{`New ${collectionLabel}`}
{`New ${collectionLabelSingular || collectionLabel}`}
</Link>
: null
}
Expand Down
1 change: 1 addition & 0 deletions website/site/content/docs/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it

- `name` (required): unique identifier for the collection, used as the key when referenced in other contexts (like the [relation widget](https://www.netlifycms.org/docs/widgets/#relation))
- `Label`: label for the collection in the editor UI; defaults to the value of `name`
- `label_singular`: singular label for certain elements in the editor; defaults to the value of `label`
- `file` or `folder` (requires one of these): specifies the collection type and location; details in [Collection Types](https://www.netlifycms.org/docs/collection-types)
- `filter`: optional filter for `folder` collections; details in [Collection Types](https://www.netlifycms.org/docs/collection-types)
- `create`: for `folder` collections only; `true` allows users to create new items in the collection; defaults to `false`
Expand Down

0 comments on commit d7ca84a

Please sign in to comment.