@vitrailweb/payload-plugin-articles 1.0.1 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/collections/Articles.js +8 -1
- package/dist/collections/Articles.js.map +1 -1
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -64,7 +64,17 @@ pnpm build # build to dist/
|
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
66
|
# commit everything
|
|
67
|
-
|
|
67
|
+
pnpm version patch # or minor/major
|
|
68
68
|
pnpm clean && pnpm build
|
|
69
69
|
pnpm pack
|
|
70
70
|
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
## Publish
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# commit everything
|
|
77
|
+
pnpm version patch # or minor/major
|
|
78
|
+
git push --follow-tags
|
|
79
|
+
# create a release on Github
|
|
80
|
+
```
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { slugField } from 'payload';
|
|
2
2
|
import { MetaDescriptionField, MetaImageField, MetaTitleField, OverviewField, PreviewField } from '@payloadcms/plugin-seo/fields';
|
|
3
|
+
import { FixedToolbarFeature, lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
3
4
|
import { label } from '../translations/index.js';
|
|
4
5
|
const seoField = (generators)=>({
|
|
5
6
|
name: 'meta',
|
|
@@ -82,7 +83,13 @@ export const Articles = ({ access, articleUrl, seo })=>({
|
|
|
82
83
|
{
|
|
83
84
|
name: 'content',
|
|
84
85
|
type: 'richText',
|
|
85
|
-
label: label((t)=>t.fields.content)
|
|
86
|
+
label: label((t)=>t.fields.content),
|
|
87
|
+
editor: lexicalEditor({
|
|
88
|
+
features: ({ defaultFeatures })=>[
|
|
89
|
+
...defaultFeatures,
|
|
90
|
+
FixedToolbarFeature()
|
|
91
|
+
]
|
|
92
|
+
})
|
|
86
93
|
},
|
|
87
94
|
{
|
|
88
95
|
name: 'publishedAt',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/collections/Articles.ts"],"sourcesContent":["import type { Access, CollectionConfig, Field } from 'payload'\nimport { slugField } from 'payload'\nimport {\n MetaDescriptionField,\n MetaImageField,\n MetaTitleField,\n OverviewField,\n PreviewField,\n} from '@payloadcms/plugin-seo/fields'\nimport { label } from '../translations/index.js'\n\nexport type ArticlesAccess = {\n create?: Access\n delete?: Access\n read?: Access\n update?: Access\n}\n\nexport type ArticlesSeoGenerators = {\n hasGenerateDescription: boolean\n hasGenerateImage: boolean\n hasGenerateTitle: boolean\n}\n\nexport type ArticlesOptions = {\n access: Required<ArticlesAccess>\n articleUrl: (slug?: string | null) => string\n seo: false | ArticlesSeoGenerators\n}\n\nconst seoField = (generators: ArticlesSeoGenerators): Field => ({\n name: 'meta',\n label: label((t) => t.fields.seo),\n type: 'group',\n admin: {\n position: 'sidebar',\n },\n fields: [\n OverviewField({\n titlePath: 'meta.title',\n descriptionPath: 'meta.description',\n imagePath: 'meta.image',\n }),\n MetaTitleField({\n hasGenerateFn: generators.hasGenerateTitle,\n overrides: {\n label: label((t) => t.fields.seoTitle),\n },\n }),\n MetaImageField({\n relationTo: 'media',\n hasGenerateFn: generators.hasGenerateImage,\n }),\n MetaDescriptionField({\n hasGenerateFn: generators.hasGenerateDescription,\n }),\n PreviewField({\n hasGenerateFn: true,\n titlePath: 'meta.title',\n descriptionPath: 'meta.description',\n }),\n ],\n})\n\nexport const Articles = ({ access, articleUrl, seo }: ArticlesOptions): CollectionConfig => ({\n slug: 'articles',\n labels: {\n singular: label((t) => t.articles.singular),\n plural: label((t) => t.articles.plural),\n },\n admin: {\n useAsTitle: 'title',\n defaultColumns: ['title', 'slug', '_status', 'publishedAt', 'updatedAt'],\n livePreview: {\n url: ({ data }) => articleUrl(data?.slug as string | undefined),\n },\n preview: (data) => articleUrl(data?.slug as string | undefined),\n },\n access: {\n read: access.read,\n create: access.create,\n update: access.update,\n delete: access.delete,\n },\n versions: {\n drafts: {\n autosave: true,\n },\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n label: label((t) => t.fields.title),\n required: true,\n },\n slugField(),\n {\n name: 'coverImage',\n type: 'upload',\n label: label((t) => t.fields.coverImage),\n relationTo: 'media',\n },\n {\n name: 'content',\n type: 'richText',\n label: label((t) => t.fields.content),\n },\n {\n name: 'publishedAt',\n type: 'date',\n label: label((t) => t.fields.publishedAt),\n admin: {\n position: 'sidebar',\n date: {\n pickerAppearance: 'dayAndTime',\n },\n },\n hooks: {\n beforeChange: [\n ({ siblingData, value }) => {\n if (siblingData._status === 'published' && !value) {\n return new Date()\n }\n return value\n },\n ],\n },\n },\n ...(seo ? [seoField(seo)] : []),\n ],\n})\n"],"names":["slugField","MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField","label","seoField","generators","name","t","fields","seo","type","admin","position","titlePath","descriptionPath","imagePath","hasGenerateFn","hasGenerateTitle","overrides","seoTitle","relationTo","hasGenerateImage","hasGenerateDescription","Articles","access","articleUrl","slug","labels","singular","articles","plural","useAsTitle","defaultColumns","livePreview","url","data","preview","read","create","update","delete","versions","drafts","autosave","title","required","coverImage","content","publishedAt","date","pickerAppearance","hooks","beforeChange","siblingData","value","_status","Date"],"mappings":"AACA,SAASA,SAAS,QAAQ,UAAS;AACnC,SACEC,oBAAoB,EACpBC,cAAc,EACdC,cAAc,EACdC,aAAa,EACbC,YAAY,QACP,gCAA+B;AACtC,SAASC,KAAK,QAAQ,2BAA0B;AAqBhD,MAAMC,WAAW,CAACC,aAA8C,CAAA;QAC9DC,MAAM;QACNH,OAAOA,MAAM,CAACI,IAAMA,EAAEC,MAAM,CAACC,GAAG;QAChCC,MAAM;QACNC,OAAO;YACLC,UAAU;QACZ;QACAJ,QAAQ;
|
|
1
|
+
{"version":3,"sources":["../../src/collections/Articles.ts"],"sourcesContent":["import type { Access, CollectionConfig, Field } from 'payload'\nimport { slugField } from 'payload'\nimport {\n MetaDescriptionField,\n MetaImageField,\n MetaTitleField,\n OverviewField,\n PreviewField,\n} from '@payloadcms/plugin-seo/fields'\nimport { FixedToolbarFeature, lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { label } from '../translations/index.js'\n\nexport type ArticlesAccess = {\n create?: Access\n delete?: Access\n read?: Access\n update?: Access\n}\n\nexport type ArticlesSeoGenerators = {\n hasGenerateDescription: boolean\n hasGenerateImage: boolean\n hasGenerateTitle: boolean\n}\n\nexport type ArticlesOptions = {\n access: Required<ArticlesAccess>\n articleUrl: (slug?: string | null) => string\n seo: false | ArticlesSeoGenerators\n}\n\nconst seoField = (generators: ArticlesSeoGenerators): Field => ({\n name: 'meta',\n label: label((t) => t.fields.seo),\n type: 'group',\n admin: {\n position: 'sidebar',\n },\n fields: [\n OverviewField({\n titlePath: 'meta.title',\n descriptionPath: 'meta.description',\n imagePath: 'meta.image',\n }),\n MetaTitleField({\n hasGenerateFn: generators.hasGenerateTitle,\n overrides: {\n label: label((t) => t.fields.seoTitle),\n },\n }),\n MetaImageField({\n relationTo: 'media',\n hasGenerateFn: generators.hasGenerateImage,\n }),\n MetaDescriptionField({\n hasGenerateFn: generators.hasGenerateDescription,\n }),\n PreviewField({\n hasGenerateFn: true,\n titlePath: 'meta.title',\n descriptionPath: 'meta.description',\n }),\n ],\n})\n\nexport const Articles = ({ access, articleUrl, seo }: ArticlesOptions): CollectionConfig => ({\n slug: 'articles',\n labels: {\n singular: label((t) => t.articles.singular),\n plural: label((t) => t.articles.plural),\n },\n admin: {\n useAsTitle: 'title',\n defaultColumns: ['title', 'slug', '_status', 'publishedAt', 'updatedAt'],\n livePreview: {\n url: ({ data }) => articleUrl(data?.slug as string | undefined),\n },\n preview: (data) => articleUrl(data?.slug as string | undefined),\n },\n access: {\n read: access.read,\n create: access.create,\n update: access.update,\n delete: access.delete,\n },\n versions: {\n drafts: {\n autosave: true,\n },\n },\n fields: [\n {\n name: 'title',\n type: 'text',\n label: label((t) => t.fields.title),\n required: true,\n },\n slugField(),\n {\n name: 'coverImage',\n type: 'upload',\n label: label((t) => t.fields.coverImage),\n relationTo: 'media',\n },\n {\n name: 'content',\n type: 'richText',\n label: label((t) => t.fields.content),\n editor: lexicalEditor({\n features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n }),\n },\n {\n name: 'publishedAt',\n type: 'date',\n label: label((t) => t.fields.publishedAt),\n admin: {\n position: 'sidebar',\n date: {\n pickerAppearance: 'dayAndTime',\n },\n },\n hooks: {\n beforeChange: [\n ({ siblingData, value }) => {\n if (siblingData._status === 'published' && !value) {\n return new Date()\n }\n return value\n },\n ],\n },\n },\n ...(seo ? [seoField(seo)] : []),\n ],\n})\n"],"names":["slugField","MetaDescriptionField","MetaImageField","MetaTitleField","OverviewField","PreviewField","FixedToolbarFeature","lexicalEditor","label","seoField","generators","name","t","fields","seo","type","admin","position","titlePath","descriptionPath","imagePath","hasGenerateFn","hasGenerateTitle","overrides","seoTitle","relationTo","hasGenerateImage","hasGenerateDescription","Articles","access","articleUrl","slug","labels","singular","articles","plural","useAsTitle","defaultColumns","livePreview","url","data","preview","read","create","update","delete","versions","drafts","autosave","title","required","coverImage","content","editor","features","defaultFeatures","publishedAt","date","pickerAppearance","hooks","beforeChange","siblingData","value","_status","Date"],"mappings":"AACA,SAASA,SAAS,QAAQ,UAAS;AACnC,SACEC,oBAAoB,EACpBC,cAAc,EACdC,cAAc,EACdC,aAAa,EACbC,YAAY,QACP,gCAA+B;AACtC,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,+BAA8B;AACjF,SAASC,KAAK,QAAQ,2BAA0B;AAqBhD,MAAMC,WAAW,CAACC,aAA8C,CAAA;QAC9DC,MAAM;QACNH,OAAOA,MAAM,CAACI,IAAMA,EAAEC,MAAM,CAACC,GAAG;QAChCC,MAAM;QACNC,OAAO;YACLC,UAAU;QACZ;QACAJ,QAAQ;YACNT,cAAc;gBACZc,WAAW;gBACXC,iBAAiB;gBACjBC,WAAW;YACb;YACAjB,eAAe;gBACbkB,eAAeX,WAAWY,gBAA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,CAACI,IAAMA,EAAEC,MAAM,CAACuC,OAAO;gBACpCC,QAAQ9C,cAAc;oBACpB+C,UAAU,CAAC,EAAEC,eAAe,EAAE,GAAK;+BAAIA;4BAAiBjD;yBAAsB;gBAChF;YACF;YACA;gBACEK,MAAM;gBACNI,MAAM;gBACNP,OAAOA,MAAM,CAACI,IAAMA,EAAEC,MAAM,CAAC2C,WAAW;gBACxCxC,OAAO;oBACLC,UAAU;oBACVwC,MAAM;wBACJC,kBAAkB;oBACpB;gBACF;gBACAC,OAAO;oBACLC,cAAc;wBACZ,CAAC,EAAEC,WAAW,EAAEC,KAAK,EAAE;4BACrB,IAAID,YAAYE,OAAO,KAAK,eAAe,CAACD,OAAO;gCACjD,OAAO,IAAIE;4BACb;4BACA,OAAOF;wBACT;qBACD;gBACH;YACF;eACIhD,MAAM;gBAACL,SAASK;aAAK,GAAG,EAAE;SAC/B;IACH,CAAA,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitrailweb/payload-plugin-articles",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Payload plugin that adds an Articles collection",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Vitrail Web"
|
|
8
8
|
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/Vitrail-Web/payload-plugin-articles"
|
|
12
|
+
},
|
|
9
13
|
"type": "module",
|
|
10
14
|
"exports": {
|
|
11
15
|
".": {
|
|
@@ -26,9 +30,9 @@
|
|
|
26
30
|
"@payloadcms/db-sqlite": "3.84.1",
|
|
27
31
|
"@payloadcms/eslint-config": "3.28.0",
|
|
28
32
|
"@payloadcms/next": "3.84.1",
|
|
33
|
+
"@payloadcms/plugin-seo": "3.84.1",
|
|
29
34
|
"@payloadcms/richtext-lexical": "3.84.1",
|
|
30
35
|
"@payloadcms/ui": "3.84.1",
|
|
31
|
-
"@payloadcms/plugin-seo": "3.84.1",
|
|
32
36
|
"@playwright/test": "1.58.2",
|
|
33
37
|
"@swc-node/register": "1.10.9",
|
|
34
38
|
"@swc/cli": "0.6.0",
|
|
@@ -56,8 +60,8 @@
|
|
|
56
60
|
"vitest": "4.0.18"
|
|
57
61
|
},
|
|
58
62
|
"peerDependencies": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
63
|
+
"@payloadcms/plugin-seo": "^3.84.1",
|
|
64
|
+
"payload": "^3.84.1"
|
|
61
65
|
},
|
|
62
66
|
"engines": {
|
|
63
67
|
"node": "^18.20.2 || >=20.9.0",
|
|
@@ -67,7 +71,6 @@
|
|
|
67
71
|
"access": "public",
|
|
68
72
|
"registry": "https://registry.npmjs.org/"
|
|
69
73
|
},
|
|
70
|
-
"dependencies": {},
|
|
71
74
|
"scripts": {
|
|
72
75
|
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
73
76
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
@@ -82,8 +85,9 @@
|
|
|
82
85
|
"generate:types": "pnpm dev:generate-types",
|
|
83
86
|
"lint": "eslint",
|
|
84
87
|
"lint:fix": "eslint ./src --fix",
|
|
85
|
-
"test": "pnpm test:int && pnpm test:e2e",
|
|
88
|
+
"test": "pnpm test:unit && pnpm test:int && pnpm test:e2e",
|
|
86
89
|
"test:e2e": "playwright test",
|
|
87
|
-
"test:int": "vitest"
|
|
90
|
+
"test:int": "vitest run dev/int.spec.ts",
|
|
91
|
+
"test:unit": "vitest run test/unit.spec.ts"
|
|
88
92
|
}
|
|
89
93
|
}
|