payload-custom-plugin
v1.1.33
Published
A sample Payload plugin
Downloads
29
Readme
payload-custom-plugin
Install the following package to generate description through AI
npm i payload-custom-plugin
In Collection file import the ContentConfig from payload-custom-plugin
import { ContentConfig } from 'payload-custom-plugin';
instead of "import { CollectionConfig } from 'payload/types';"
Add OPENAI_API_KEY in .env file
OPENAI_API_KEY="Your OPEN API KEY"
Set autoDescription in constant in collection
autoDescription: true,
For which field want to generate description through AI provide name as "Title_"fieldname"" and where these description needs to show set the name of field as "Description_"fieldname"" e.g. " { name: 'Title_Tagline', type: 'text', label: 'Any Label', required: true, }, { name: 'Description_Tagline', type: 'textarea', label: 'Any label', admin: { condition: (_, siblingData) => !!siblingData.Description, }, }, "
For multiple fields generate the description according to Field value, give the field names after "Title_" and "Description_" e.g. " { name: 'Title_BulletedPoints', type: 'text', label: 'Any label', required: true, }, { name: 'Description_BulletedPoints', type: 'textarea', label: 'Any label', admin: { condition: (_, siblingData) => !!siblingData.Description, }, }, "
In payload.config.ts file import ContentGenerator from payload-custom-plugin
import ContentGenerator from 'payload-custom-plugin';
Define the collection in plugin instead of collections
plugins: [
ContentGenerator(collection_name),
],
run npm dev
While generating the content in payload dashboard use following indentations, e.g If you want to generate tagline for AWS use title field like "tagline : AWS"
If you want to generate description for AWS use title field like "description : AWS", you can provide word limit also before ":" like "100 word description : AWS"