When only a partial `labels` config is defined on a collection, the
collection defaults do not apply as expected. This leads to undefined
`singular` or `plural` properties that render as either empty or
untranslated strings on the front-end.
For example:
```ts
import type { CollectionConfig } from 'payload'
export MyCollection: CollectionConfig = {
// ...
labels: {
plural: 'Pages', // Notice that `singular` is excluded here
},
}
```
This renders empty or untranslated strings throughout the admin panel,
here are a couple examples:
<img width="326" height="211" alt="Screenshot 2025-09-26 at 10 27 40 AM"
src="https://github.com/user-attachments/assets/3872c4dd-0dac-4c1c-b417-61ddd042bbb8"
/>
<img width="330" height="267" alt="Screenshot 2025-09-26 at 10 27 51 AM"
src="https://github.com/user-attachments/assets/78772405-b5f3-45fa-9bf0-bc078f1ba976"
/>
---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
- https://app.asana.com/0/0/1211478736160147
140 lines
3.2 KiB
TypeScript
140 lines
3.2 KiB
TypeScript
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { devUser } from '../credentials.js'
|
|
|
|
export default buildConfigWithDefaults({
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
collections: [
|
|
{
|
|
slug: 'pages',
|
|
labels: {
|
|
// Purposefully exclude `singular` to test default inheritance
|
|
plural: 'Pages',
|
|
},
|
|
access: {
|
|
create: () => true,
|
|
delete: () => true,
|
|
read: () => true,
|
|
update: () => true,
|
|
},
|
|
custom: {
|
|
externalLink: 'https://foo.bar',
|
|
},
|
|
endpoints: [
|
|
{
|
|
custom: { examples: [{ type: 'response', value: { message: 'hi' } }] },
|
|
handler: () => {
|
|
return Response.json({ message: 'hi' })
|
|
},
|
|
method: 'get',
|
|
path: '/hello',
|
|
},
|
|
],
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
custom: {
|
|
description: 'The title of this page',
|
|
},
|
|
},
|
|
{
|
|
name: 'myBlocks',
|
|
type: 'blocks',
|
|
blocks: [
|
|
{
|
|
slug: 'blockOne',
|
|
custom: {
|
|
description: 'The blockOne of this page',
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'blockOneField',
|
|
type: 'text',
|
|
},
|
|
{
|
|
name: 'blockTwoField',
|
|
type: 'text',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
custom: {
|
|
description: 'The blocks of this page',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
custom: { name: 'Customer portal' },
|
|
endpoints: [
|
|
{
|
|
custom: { description: 'Get the sanitized payload config' },
|
|
handler: (req) => {
|
|
return Response.json(req.payload.config)
|
|
},
|
|
method: 'get',
|
|
path: '/config',
|
|
},
|
|
],
|
|
bin: [
|
|
{
|
|
scriptPath: path.resolve(dirname, 'customScript.ts'),
|
|
key: 'start-server',
|
|
},
|
|
],
|
|
globals: [
|
|
{
|
|
slug: 'my-global',
|
|
custom: { foo: 'bar' },
|
|
endpoints: [
|
|
{
|
|
custom: { params: [{ name: 'name', type: 'string', in: 'query' }] },
|
|
handler: (req) => {
|
|
const sp = new URL(req.url).searchParams
|
|
return Response.json({ message: `Hi ${sp.get('name')}!` })
|
|
},
|
|
method: 'get',
|
|
path: '/greet',
|
|
},
|
|
],
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
type: 'text',
|
|
custom: {
|
|
description: 'The title of my global',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
onInit: async (payload) => {
|
|
const { totalDocs } = await payload.count({ collection: 'users' })
|
|
|
|
if (totalDocs === 0) {
|
|
await payload.create({
|
|
collection: 'users',
|
|
data: {
|
|
email: devUser.email,
|
|
password: devUser.password,
|
|
},
|
|
})
|
|
}
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
cors: {
|
|
origins: '*',
|
|
headers: ['x-custom-header'],
|
|
},
|
|
})
|