Skip to content

Commit 49894d9

Browse files
Pedro Duarteverythorough
Pedro Duarte
authored andcommitted
Add label_singular to collection config (#1086)
1 parent 952a6d5 commit 49894d9

File tree

8 files changed

+25
-8
lines changed

8 files changed

+25
-8
lines changed

.all-contributorsrc

+11
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,17 @@
750750
"code"
751751
]
752752
},
753+
{
754+
"login": "peduarte",
755+
"name": "Pedro Duarte",
756+
"avatar_url": "https://avatars1.githubusercontent.com/u/372831?v=4",
757+
"profile": "http://pedroduarte.me",
758+
"contributions": [
759+
"bug",
760+
"code",
761+
"doc"
762+
]
763+
},
753764
{
754765
"login": "Strangehill",
755766
"name": "Antonio Argote",

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Netlify CMS
2-
[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg)](#contributors)
2+
[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg)](#contributors)
33
[![Open Source Helpers](https://www.codetriage.com/netlify/netlify-cms/badges/users.svg)](https://www.codetriage.com/netlify/netlify-cms)
44
[![](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/netlify/netlifycms)
55

@@ -61,8 +61,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
6161
| [<img src="https://avatars0.githubusercontent.com/u/250958?v=4" width="100px;"/><br /><sub><b>Etienne Bernard</b></sub>](https://github.com/ebernard)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=ebernard "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/871660?v=4" width="100px;"/><br /><sub><b>Eli Williamson</b></sub>](http://eliwilliamson.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=eliwilliamson "Code") [🎨](#design-eliwilliamson "Design") | [<img src="https://avatars0.githubusercontent.com/u/858837?v=4" width="100px;"/><br /><sub><b>Covington Doan</b></sub>](https://www.covingtondoan.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=covingtondoan "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1299080?v=4" width="100px;"/><br /><sub><b>Lennart Ziburski</b></sub>](http://lennartziburski.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=ziburski "Code") [🎨](#design-ziburski "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=ziburski "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/387640?v=4" width="100px;"/><br /><sub><b>Darrel O'Pry</b></sub>](http://darrelopry.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=dopry "Code") [🚇](#infra-dopry "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/netlify/netlify-cms/commits?author=dopry "Tests") | [<img src="https://avatars1.githubusercontent.com/u/13856868?v=4" width="100px;"/><br /><sub><b>Erin Symons</b></sub>](https://github.com/yourfrienderin)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=yourfrienderin "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/5200555?v=4" width="100px;"/><br /><sub><b>Austin Green</b></sub>](https://github.com/AustinGreen)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=AustinGreen "Documentation") [💡](#example-AustinGreen "Examples") |
6262
| [<img src="https://avatars2.githubusercontent.com/u/799360?v=4" width="100px;"/><br /><sub><b>Bryan Robinson</b></sub>](http://bryanlrobinson.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=brob "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/561983?v=4" width="100px;"/><br /><sub><b>Darren</b></sub>](https://github.com/dardub)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=dardub "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/576512?v=4" width="100px;"/><br /><sub><b>Richard Pullinger</b></sub>](http://www.richardpullinger.com)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=rpullinger "Code") | [<img src="https://avatars1.githubusercontent.com/u/3718939?v=4" width="100px;"/><br /><sub><b>Taylor Bryant</b></sub>](https://taylorbryant.blog)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=taylorbryant "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/5881826?v=4" width="100px;"/><br /><sub><b>kvanerkelens</b></sub>](https://github.com/kvanerkelens)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=kvanerkelens "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/8291663?v=4" width="100px;"/><br /><sub><b>Patrick Sier</b></sub>](https://patsier.com/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=pjsier "Code") | [<img src="https://avatars2.githubusercontent.com/u/6132191?v=4" width="100px;"/><br /><sub><b>Christian Nolte</b></sub>](http://noltech.net)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=drlogout "Code") |
6363
| [<img src="https://avatars1.githubusercontent.com/u/3818?v=4" width="100px;"/><br /><sub><b>Edward Betts</b></sub>](http://edwardbetts.com/)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=EdwardBetts "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/8771435?v=4" width="100px;"/><br /><sub><b>Josh Hardman</b></sub>](https://github.com/jhardman0830)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=jhardman0830 "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/11616378?v=4" width="100px;"/><br /><sub><b>Mantas</b></sub>](https://behance.net/mistermantas)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=mistermantas "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/5244986?v=4" width="100px;"/><br /><sub><b>Marco Biedermann</b></sub>](https://www.marcobiedermann.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=marcobiedermann "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/7525670?v=4" width="100px;"/><br /><sub><b>Max Stoiber</b></sub>](https://mxstbr.blog/newsletter)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=mxstbr "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/89368?v=4" width="100px;"/><br /><sub><b>Vyacheslav Matyukhin</b></sub>](http://berekuk.ru)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=berekuk "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/9059048?v=4" width="100px;"/><br /><sub><b>jimmaaay</b></sub>](https://jimmythompson.me)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=jimmaaay "Code") |
64-
| [<img src="https://avatars3.githubusercontent.com/u/802086?v=4" width="100px;"/><br /><sub><b>Luís Miguel</b></sub>](https://github.com/Quicksaver)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [<img src="https://avatars2.githubusercontent.com/u/357379?v=4" width="100px;"/><br /><sub><b>Chris Swithinbank</b></sub>](http://chrisswithinbank.net/)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1262221?v=4" width="100px;"/><br /><sub><b>remmah</b></sub>](https://github.com/remmah)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/29388?v=4" width="100px;"/><br /><sub><b>Sumeet Jain</b></sub>](http://sumeetjain.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/26816046?v=4" width="100px;"/><br /><sub><b>Sagar Khatri</b></sub>](https://github.com/ragasirtahk)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [<img src="https://avatars0.githubusercontent.com/u/8182932?v=4" width="100px;"/><br /><sub><b>Kevin Doocey</b></sub>](https://www.dooceykev.in)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [<img src="https://avatars0.githubusercontent.com/u/31023010?v=4" width="100px;"/><br /><sub><b>Swieckowski</b></sub>](https://www.linkedin.com/in/arthur-swieckowski/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") |
65-
| [<img src="https://avatars2.githubusercontent.com/u/283419?v=4" width="100px;"/><br /><sub><b>Tim Carry</b></sub>](http://www.pixelastic.com/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/30510616?v=4" width="100px;"/><br /><sub><b>Sol Park</b></sub>](https://github.com/solpark)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [<img src="https://avatars0.githubusercontent.com/u/29218846?v=4" width="100px;"/><br /><sub><b>Michael Romani</b></sub>](https://github.com/michaelromani)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=michaelromani "Code") | [<img src="https://avatars1.githubusercontent.com/u/6064830?v=4" width="100px;"/><br /><sub><b>Antonio Argote</b></sub>](http://antonioargote.com)<br />[🎨](#design-Strangehill "Design") |
64+
| [<img src="https://avatars3.githubusercontent.com/u/802086?v=4" width="100px;"/><br /><sub><b>Luís Miguel</b></sub>](https://github.com/Quicksaver)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3AQuicksaver "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=Quicksaver "Code") | [<img src="https://avatars2.githubusercontent.com/u/357379?v=4" width="100px;"/><br /><sub><b>Chris Swithinbank</b></sub>](http://chrisswithinbank.net/)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=delucis "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/1262221?v=4" width="100px;"/><br /><sub><b>remmah</b></sub>](https://github.com/remmah)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=remmah "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/29388?v=4" width="100px;"/><br /><sub><b>Sumeet Jain</b></sub>](http://sumeetjain.com)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=sumeetjain "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/26816046?v=4" width="100px;"/><br /><sub><b>Sagar Khatri</b></sub>](https://github.com/ragasirtahk)<br />[📖](https://github.com/netlify/netlify-cms/commits?author=ragasirtahk "Documentation") [💡](#example-ragasirtahk "Examples") | [<img src="https://avatars0.githubusercontent.com/u/8182932?v=4" width="100px;"/><br /><sub><b>Kevin Doocey</b></sub>](https://www.dooceykev.in)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=Doocey "Code") | [<img src="https://avatars2.githubusercontent.com/u/283419?v=4" width="100px;"/><br /><sub><b>Tim Carry</b></sub>](http://www.pixelastic.com/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Code") [🎨](#design-pixelastic "Design") [📖](https://github.com/netlify/netlify-cms/commits?author=pixelastic "Documentation") |
65+
| [<img src="https://avatars0.githubusercontent.com/u/31023010?v=4" width="100px;"/><br /><sub><b>Swieckowski</b></sub>](https://www.linkedin.com/in/arthur-swieckowski/)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Documentation") [⚠️](https://github.com/netlify/netlify-cms/commits?author=Swieckowski "Tests") | [<img src="https://avatars0.githubusercontent.com/u/30510616?v=4" width="100px;"/><br /><sub><b>Sol Park</b></sub>](https://github.com/solpark)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=solpark "Code") | [<img src="https://avatars0.githubusercontent.com/u/29218846?v=4" width="100px;"/><br /><sub><b>Michael Romani</b></sub>](https://github.com/michaelromani)<br />[💻](https://github.com/netlify/netlify-cms/commits?author=michaelromani "Code") | [<img src="https://avatars1.githubusercontent.com/u/372831?v=4" width="100px;"/><br /><sub><b>Pedro Duarte</b></sub>](http://pedroduarte.me)<br />[🐛](https://github.com/netlify/netlify-cms/issues?q=author%3Apeduarte "Bug reports") [💻](https://github.com/netlify/netlify-cms/commits?author=peduarte "Code") [📖](https://github.com/netlify/netlify-cms/commits?author=peduarte "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/6064830?v=4" width="100px;"/><br /><sub><b>Antonio Argote</b></sub>](http://antonioargote.com)<br />[🎨](#design-Strangehill "Design") |
6666
<!-- ALL-CONTRIBUTORS-LIST:END -->
6767

6868
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

example/config.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ media_folder: "assets/uploads"
66

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

2425
- name: "faq" # Used in routes, ie.: /admin/collections/:slug/edit
25-
label: "FAQ" # Used in the UI, ie.: "New Post"
26+
label: "FAQ" # Used in the UI
2627
folder: "_faqs"
2728
create: true # Allow users to create new documents in this collection
2829
fields: # The fields each document in this collection have
@@ -56,6 +57,7 @@ collections: # A list of collections the CMS should be able to edit
5657
fields:
5758
- name: authors
5859
label: Authors
60+
label_singular: "Author"
5961
widget: list
6062
fields:
6163
- {label: "Name", name: "name", widget: "string"}

src/components/App/Header.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default class Header extends React.Component {
7373
collections.filter(collection => collection.get('create')).toList().map(collection =>
7474
<DropdownItem
7575
key={collection.get("name")}
76-
label={collection.get("label")}
76+
label={collection.get("label_singular") || collection.get("label")}
7777
onClick={() => this.handleCreatePostClick(collection.get('name'))}
7878
/>
7979
)

src/components/Collection/Collection.js

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Collection extends React.Component {
4646
? null
4747
: <CollectionTop
4848
collectionLabel={collection.get('label')}
49+
collectionLabelSingular={collection.get('label_singular')}
4950
collectionDescription={collection.get('description')}
5051
newEntryUrl={newEntryUrl}
5152
viewStyle={this.state.viewStyle}

src/components/Collection/CollectionTop.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { VIEW_STYLE_LIST, VIEW_STYLE_GRID } from 'Constants/collectionViews';
77

88
const CollectionTop = ({
99
collectionLabel,
10+
collectionLabelSingular,
1011
collectionDescription,
1112
viewStyle,
1213
onChangeViewStyle,
@@ -19,7 +20,7 @@ const CollectionTop = ({
1920
{
2021
newEntryUrl
2122
? <Link className="nc-collectionPage-topNewButton" to={newEntryUrl}>
22-
{`New ${collectionLabel}`}
23+
{`New ${collectionLabelSingular || collectionLabel}`}
2324
</Link>
2425
: null
2526
}

src/components/EditorWidgets/List/ListControl.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,13 @@ export default class ListControl extends Component {
254254
const { value, forID, field, classNameWrapper } = this.props;
255255
const { itemsCollapsed } = this.state;
256256
const items = value || List();
257+
const label = field.get('label_singular') || field.get('label');
257258

258259
return (
259260
<div id={forID} className={c(classNameWrapper, 'nc-listControl')}>
260261
<TopBar
261262
onAdd={this.handleAdd}
262-
listLabel={field.get('label').toLowerCase()}
263+
listLabel={label.toLowerCase()}
263264
onCollapseAllToggle={this.handleCollapseAllToggle}
264265
allItemsCollapsed={itemsCollapsed.every(val => val === true)}
265266
itemsCount={items.size}

website/site/content/docs/configuration-options.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ The `collections` setting is the heart of your Netlify CMS configuration, as it
7171

7272
- `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))
7373
- `Label`: label for the collection in the editor UI; defaults to the value of `name`
74+
- `label_singular`: singular label for certain elements in the editor; defaults to the value of `label`
7475
- `file` or `folder` (requires one of these): specifies the collection type and location; details in [Collection Types](https://www.netlifycms.org/docs/collection-types)
7576
- `filter`: optional filter for `folder` collections; details in [Collection Types](https://www.netlifycms.org/docs/collection-types)
7677
- `create`: for `folder` collections only; `true` allows users to create new items in the collection; defaults to `false`

0 commit comments

Comments
 (0)