From 1cc87bd8ea575dfa2e1f5ce5b38414bbba95b2cb Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Tue, 12 Dec 2023 10:51:03 -0500 Subject: [PATCH] fix(plugin-nested-docs): properly exports field utilities (#4462) --- packages/plugin-nested-docs/README.md | 47 +++++++++---------- .../src/fields/breadcrumbs.ts | 2 +- .../plugin-nested-docs/src/fields/parent.ts | 2 +- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/packages/plugin-nested-docs/README.md b/packages/plugin-nested-docs/README.md index 0d25a9ada9..704ffb9a05 100644 --- a/packages/plugin-nested-docs/README.md +++ b/packages/plugin-nested-docs/README.md @@ -22,36 +22,35 @@ Core features: In the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview), call the plugin with [options](#options): ```js -import { buildConfig } from "payload/config"; -import nestedDocs from "@payloadcms/plugin-nested-docs"; +import { buildConfig } from 'payload/config' +import nestedDocs from '@payloadcms/plugin-nested-docs' const config = buildConfig({ collections: [ { - slug: "pages", + slug: 'pages', fields: [ { - name: "title", - type: "text", + name: 'title', + type: 'text', }, { - name: "slug", - type: "text", + name: 'slug', + type: 'text', }, ], }, ], plugins: [ nestedDocs({ - collections: ["pages"], + collections: ['pages'], generateLabel: (_, doc) => doc.title, - generateURL: (docs) => - docs.reduce((url, doc) => `${url}/${doc.slug}`, ""), + generateURL: (docs) => docs.reduce((url, doc) => `${url}/${doc.slug}`, ''), }), ], -}); +}) -export default config; +export default config ``` ### Fields @@ -135,8 +134,8 @@ You can also extend the built-in `parent` and `breadcrumbs` fields per collectio ```js import { CollectionConfig } from "payload/types"; -import createParentField from "@payloadcms/plugin-nested-docs/fields/parent"; -import createBreadcrumbsField from "@payloadcms/plugin-nested-docs/fields/breadcrumbs"; +import { createParentField } from "@payloadcms/plugin-nested-docs/fields"; +import { createBreadcrumbsField } from "@payloadcms/plugin-nested-docs/fields"; const examplePageConfig: CollectionConfig = { slug: "pages", @@ -181,11 +180,7 @@ This plugin supports localization by default. If the `localization` property is All types can be directly imported: ```js -import { - PluginConfig, - GenerateURL, - GenerateLabel, -} from "@payloadcms/plugin-nested-docs/types"; +import { PluginConfig, GenerateURL, GenerateLabel } from '@payloadcms/plugin-nested-docs/types' ``` ## Development @@ -219,7 +214,7 @@ To actively develop or debug this plugin you can either work directly within the You might also need to alias these modules in your Webpack config. To do this, open your project's Payload config and add the following: ```js - import { buildConfig } from "payload/config"; + import { buildConfig } from 'payload/config' export default buildConfig({ admin: { @@ -229,18 +224,18 @@ To actively develop or debug this plugin you can either work directly within the ...config.resolve, alias: { ...config.resolve.alias, - react: path.join(__dirname, "../node_modules/react"), - "react-dom": path.join(__dirname, "../node_modules/react-dom"), - payload: path.join(__dirname, "../node_modules/payload"), - "@payloadcms/plugin-nested-docs": path.join( + react: path.join(__dirname, '../node_modules/react'), + 'react-dom': path.join(__dirname, '../node_modules/react-dom'), + payload: path.join(__dirname, '../node_modules/payload'), + '@payloadcms/plugin-nested-docs': path.join( __dirname, - "../../payload/plugin-nested-docs/src" + '../../payload/plugin-nested-docs/src', ), }, }, }), }, - }); + }) ``` ## Screenshots diff --git a/packages/plugin-nested-docs/src/fields/breadcrumbs.ts b/packages/plugin-nested-docs/src/fields/breadcrumbs.ts index ba746cfa9c..a79d5d4fe4 100644 --- a/packages/plugin-nested-docs/src/fields/breadcrumbs.ts +++ b/packages/plugin-nested-docs/src/fields/breadcrumbs.ts @@ -1,6 +1,6 @@ import type { ArrayField, Field } from 'payload/types' -const createBreadcrumbsField = ( +export const createBreadcrumbsField = ( relationTo: string, overrides: Partial = {}, ): Field => ({ diff --git a/packages/plugin-nested-docs/src/fields/parent.ts b/packages/plugin-nested-docs/src/fields/parent.ts index e39dbc6ce5..92212cb451 100644 --- a/packages/plugin-nested-docs/src/fields/parent.ts +++ b/packages/plugin-nested-docs/src/fields/parent.ts @@ -1,6 +1,6 @@ import type { SingleRelationshipField } from 'payload/types' -const createParentField = ( +export const createParentField = ( relationTo: string, overrides?: Partial< SingleRelationshipField & {