Currently the name defaults to the slug Blogcategories, I'd like to set the name Blog Categories?
import { CollectionConfig } from 'payload/types';
const BlogCategories: CollectionConfig = {
slug: 'blogcategories',
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
fields: [
{
name: 'name',
type: 'text',
},
],
timestamps: false,
};
export default BlogCategories;
Good afternoon @taun2160 !
Check out the "labels" property on collections
https://payloadcms.com/docs/configuration/collections
Oh yes, forgot about labels.. Thanks Chris.
No prob 😄
How is it written? Clearly not like this:
import { CollectionConfig } from 'payload/types';
const BlogCategories: CollectionConfig = {
slug: 'blog_categories',
label: 'Blog Categories',
admin: {
useAsTitle: 'name',
},
access: {
read: () => true,
},
fields: [
{
name: 'name',
type: 'text',
},
],
timestamps: false,
};
export default BlogCategories;
In the docs i found an example of a field label in use, but not for the name of the collection
fields: [
{
name: 'title',
label: 'Page Title',
type: 'text',
required: true,
localized: true,
},
Pretty sure the automatic labels also respect camel case. So setting the slug to
blogCategories
should also work.
By naming it do you mean labeling it? Or sluggin it?
Haha sorry just updated my message 😂
Haha, cool, thanks. I assume camelcase is also GraphQL friendly?
I received a graphql regarding the name, not sure what that was about.
Do you know how I can define the label, instead of using the slug?
To change the label of the collection, use
labels
on your collection config.
labels: {
singular: 'Blog Category',
plural: 'Blog Categories'
}
I was gonna link to the docs, but looks like we don't use the
labels
property in the examples (
https://payloadcms.com/docs/configuration/collections). Probably a good PR opportunity there. 😄
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.