Skip to content
Open
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
17 changes: 15 additions & 2 deletions packages/plugin-nested-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
"import": "./src/exports/types.ts",
"types": "./src/exports/types.ts",
"default": "./src/exports/types.ts"
},
"./translations/languages/all": {
"import": "./src/translations/index.ts",
"types": "./src/translations/index.ts",
"default": "./src/translations/index.ts"
},
"./translations/languages/*": {
"import": "./src/translations/languages/*.ts",
"types": "./src/translations/languages/*.ts",
"default": "./src/translations/languages/*.ts"
}
},
"main": "./src/index.ts",
Expand All @@ -46,10 +56,13 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"devDependencies": {
"@payloadcms/eslint-config": "workspace:*",
"dependencies": {
"@payloadcms/translations": "workspace:*",
"payload": "workspace:*"
},
"devDependencies": {
"@payloadcms/eslint-config": "workspace:*"
},
"peerDependencies": {
"payload": "workspace:*"
},
Expand Down
13 changes: 12 additions & 1 deletion packages/plugin-nested-docs/src/fields/breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const createBreadcrumbsField = (
): Field => ({
name: 'breadcrumbs',
type: 'array',
labels: {
// @ts-expect-error - translations are not typed in plugins yet
plural: ({ t }) => t('plugin-nested-docs:breadcrumbsPlural'),
// @ts-expect-error - translations are not typed in plugins yet
singular: ({ t }) => t('plugin-nested-docs:breadcrumbsSingular'),
},
localized: true,
...(overrides || {}),
admin: {
Expand All @@ -19,6 +25,8 @@ export const createBreadcrumbsField = (
admin: {
disabled: true,
},
// @ts-expect-error - translations are not typed in plugins yet
label: ({ t }) => t('plugin-nested-docs:doc'),
maxDepth: 0,
relationTo,
},
Expand All @@ -31,14 +39,17 @@ export const createBreadcrumbsField = (
admin: {
width: '50%',
},
label: 'URL',
// @ts-expect-error - translations are not typed in plugins yet
label: ({ t }) => t('plugin-nested-docs:url'),
},
{
name: 'label',
type: 'text',
admin: {
width: '50%',
},
// @ts-expect-error - translations are not typed in plugins yet
label: ({ t }) => t('plugin-nested-docs:label'),
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-nested-docs/src/fields/parent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const createParentField = (
position: 'sidebar',
...(overrides?.admin || {}),
},
// @ts-expect-error - translations are not typed in plugins yet
label: ({ t }) => t('plugin-nested-docs:parent'),
// filterOptions are assigned dynamically based on the pluginConfig
// filterOptions: parentFilterOptions(),
type: 'relationship',
Expand Down
8 changes: 8 additions & 0 deletions packages/plugin-nested-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { SingleRelationshipField } from 'payload'

import { definePlugin } from 'payload'

import { deepMergeSimple } from 'payload/shared'

import type { NestedDocsPluginConfig } from './types.js'

import { createBreadcrumbsField } from './fields/breadcrumbs.js'
Expand All @@ -10,7 +12,9 @@ import { parentFilterOptions } from './fields/parentFilterOptions.js'
import { populateBreadcrumbsBeforeChange } from './hooks/populateBreadcrumbsBeforeChange.js'
import { resaveChildren } from './hooks/resaveChildren.js'
import { resaveSelfAfterCreate } from './hooks/resaveSelfAfterCreate.js'
import { translations } from './translations/index.js'
import { getParents } from './utilities/getParents.js'
export { translations as nestedDocsTranslations } from './translations/index.js'

export { createBreadcrumbsField, createParentField, getParents }

Expand Down Expand Up @@ -69,5 +73,9 @@ export const nestedDocsPlugin = definePlugin<NestedDocsPluginConfig>({

return collection
}),
i18n: {
...config.i18n,
translations: deepMergeSimple(translations, config.i18n?.translations ?? {}),
},
}),
})
15 changes: 15 additions & 0 deletions packages/plugin-nested-docs/src/translations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { GenericTranslationsObject, NestedKeysStripped } from '@payloadcms/translations'

import { de } from './languages/de.js'
import { en } from './languages/en.js'
import { it } from './languages/it.js'

export const translations = {
de,
en,
it,
}

export type PluginNestedDocsTranslations = GenericTranslationsObject

export type PluginNestedDocsTranslationKeys = NestedKeysStripped<PluginNestedDocsTranslations>
13 changes: 13 additions & 0 deletions packages/plugin-nested-docs/src/translations/languages/de.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { GenericTranslationsObject } from '@payloadcms/translations'

export const de: GenericTranslationsObject = {
$schema: '../translation-schema.json',
'plugin-nested-docs': {
breadcrumbsPlural: 'Navigationspfade',
breadcrumbsSingular: 'Navigationspfad',
doc: 'Dokument',
label: 'Bezeichnung',
parent: 'Übergeordnetes Dokument',
url: 'URL',
},
}
13 changes: 13 additions & 0 deletions packages/plugin-nested-docs/src/translations/languages/en.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { GenericTranslationsObject } from '@payloadcms/translations'

export const en: GenericTranslationsObject = {
$schema: '../translation-schema.json',
'plugin-nested-docs': {
breadcrumbsPlural: 'Breadcrumbs',
breadcrumbsSingular: 'Breadcrumb',
doc: 'Document',
label: 'Label',
parent: 'Parent Document',
url: 'URL',
},
}
13 changes: 13 additions & 0 deletions packages/plugin-nested-docs/src/translations/languages/it.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { GenericTranslationsObject } from '@payloadcms/translations'

export const it: GenericTranslationsObject = {
$schema: '../translation-schema.json',
'plugin-nested-docs': {
breadcrumbsPlural: 'Percorsi di navigazione',
breadcrumbsSingular: 'Percorso di navigazione',
doc: 'Documento',
label: 'Etichetta',
parent: 'Documento genitore',
url: 'URL',
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string"
},
"plugin-nested-docs": {
"type": "object",
"additionalProperties": false,
"properties": {
"breadcrumbsPlural": {
"type": "string"
},
"breadcrumbsSingular": {
"type": "string"
},
"doc": {
"type": "string"
},
"label": {
"type": "string"
},
"parent": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": ["breadcrumbsPlural", "breadcrumbsSingular", "doc", "label", "parent", "url"]
}
},
"required": ["plugin-nested-docs"]
}
3 changes: 3 additions & 0 deletions packages/plugin-nested-docs/src/translations/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { en } from './languages/en.js'

export type PluginDefaultTranslationsObject = typeof en
2 changes: 1 addition & 1 deletion test/plugin-nested-docs/collections/Pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const Pages: CollectionConfig = {
},
admin: {
components: {
Field: null,
Field: undefined,
},
},
},
Expand Down
Loading