@zedtech/zedkit-payload-seo 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +24 -2
- package/dist/fields.d.ts +23 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +90 -0
- package/dist/fields.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zedtech-fr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zedtech/zedkit-payload-seo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Localized Payload SEO group field with length validation.
|
|
4
|
+
Original work by the same author.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
pnpm add @zedtech/zedkit-payload-seo
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { seoGroupField } from "@zedtech/zedkit-payload-seo";
|
|
12
|
+
|
|
13
|
+
export const Page = {
|
|
14
|
+
slug: "pages",
|
|
15
|
+
fields: [/* ... */, seoGroupField()],
|
|
16
|
+
};
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`seoFields()` returns the nine leaf fields (meta title/description,
|
|
20
|
+
keywords, canonical URL, OG title/description/image, robots
|
|
21
|
+
noindex/nofollow); `seoGroupField()` wraps them in a group (default
|
|
22
|
+
name `"seo"`). Text lengths are capped (70/160) with friendly
|
|
23
|
+
validator messages; the OG image uploads to your media collection
|
|
24
|
+
(`mediaSlug` option). Pair with `@zedtech/zedkit-seo` to turn stored values
|
|
25
|
+
into metadata, sitemaps, and JSON-LD.
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Field } from "payload";
|
|
2
|
+
export declare const SEO_TITLE_MAX = 70;
|
|
3
|
+
export declare const SEO_DESCRIPTION_MAX = 160;
|
|
4
|
+
/** Length validator with a friendly message (empty and non-strings pass). */
|
|
5
|
+
export declare function maxLengthValidator(max: number): (value: unknown) => string | true;
|
|
6
|
+
export interface SeoFieldsOptions {
|
|
7
|
+
/** Upload collection for the OG image. Defaults to `"media"`. */
|
|
8
|
+
mediaSlug?: string;
|
|
9
|
+
/** Meta/OG title cap. Defaults to 70. */
|
|
10
|
+
titleMaxLength?: number;
|
|
11
|
+
/** Meta/OG description cap. Defaults to 160. */
|
|
12
|
+
descriptionMaxLength?: number;
|
|
13
|
+
/** Group field name. Defaults to `"seo"`. */
|
|
14
|
+
groupName?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Localized SEO leaf fields: meta title/description, keywords,
|
|
18
|
+
* canonical URL, OG title/description/image, robots flags.
|
|
19
|
+
*/
|
|
20
|
+
export declare function seoFields(options?: SeoFieldsOptions): Field[];
|
|
21
|
+
/** The leaf fields wrapped in a group (default name `"seo"`). */
|
|
22
|
+
export declare function seoGroupField(options?: SeoFieldsOptions): Field;
|
|
23
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,CAKjF;AAED,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,KAAK,EAAE,CAkEjE;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,OAAO,GAAE,gBAAqB,GAAG,KAAK,CAMnE"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const SEO_TITLE_MAX = 70;
|
|
2
|
+
export const SEO_DESCRIPTION_MAX = 160;
|
|
3
|
+
/** Length validator with a friendly message (empty and non-strings pass). */
|
|
4
|
+
export function maxLengthValidator(max) {
|
|
5
|
+
return (value) => {
|
|
6
|
+
if (typeof value !== "string" || value.length === 0)
|
|
7
|
+
return true;
|
|
8
|
+
return value.length <= max ? true : `Must be ${max} characters or fewer (now ${value.length}).`;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Localized SEO leaf fields: meta title/description, keywords,
|
|
13
|
+
* canonical URL, OG title/description/image, robots flags.
|
|
14
|
+
*/
|
|
15
|
+
export function seoFields(options = {}) {
|
|
16
|
+
const mediaSlug = options.mediaSlug ?? "media";
|
|
17
|
+
const titleMax = options.titleMaxLength ?? SEO_TITLE_MAX;
|
|
18
|
+
const descriptionMax = options.descriptionMaxLength ?? SEO_DESCRIPTION_MAX;
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
name: "metaTitle",
|
|
22
|
+
type: "text",
|
|
23
|
+
localized: true,
|
|
24
|
+
maxLength: titleMax,
|
|
25
|
+
validate: maxLengthValidator(titleMax),
|
|
26
|
+
admin: { description: `Search result title (${titleMax} chars max).` },
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "metaDescription",
|
|
30
|
+
type: "textarea",
|
|
31
|
+
localized: true,
|
|
32
|
+
maxLength: descriptionMax,
|
|
33
|
+
validate: maxLengthValidator(descriptionMax),
|
|
34
|
+
admin: { description: `Search result snippet (${descriptionMax} chars max).` },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "keywords",
|
|
38
|
+
type: "array",
|
|
39
|
+
localized: true,
|
|
40
|
+
fields: [{ name: "value", type: "text" }],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "canonicalUrl",
|
|
44
|
+
type: "text",
|
|
45
|
+
admin: { description: "Absolute URL; leave empty to use the page URL." },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "ogTitle",
|
|
49
|
+
type: "text",
|
|
50
|
+
localized: true,
|
|
51
|
+
maxLength: titleMax,
|
|
52
|
+
validate: maxLengthValidator(titleMax),
|
|
53
|
+
admin: { description: "Social share title; falls back to the meta title." },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "ogDescription",
|
|
57
|
+
type: "textarea",
|
|
58
|
+
localized: true,
|
|
59
|
+
maxLength: descriptionMax,
|
|
60
|
+
validate: maxLengthValidator(descriptionMax),
|
|
61
|
+
admin: { description: "Social share text; falls back to the meta description." },
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "ogImage",
|
|
65
|
+
type: "upload",
|
|
66
|
+
relationTo: mediaSlug,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "robotsNoIndex",
|
|
70
|
+
type: "checkbox",
|
|
71
|
+
defaultValue: false,
|
|
72
|
+
admin: { description: "Hide this page from search results (drafts)." },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "robotsNoFollow",
|
|
76
|
+
type: "checkbox",
|
|
77
|
+
defaultValue: false,
|
|
78
|
+
admin: { description: "Tell crawlers not to follow this page's links." },
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
/** The leaf fields wrapped in a group (default name `"seo"`). */
|
|
83
|
+
export function seoGroupField(options = {}) {
|
|
84
|
+
return {
|
|
85
|
+
name: options.groupName ?? "seo",
|
|
86
|
+
type: "group",
|
|
87
|
+
fields: seoFields(options),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAAC,GAA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E,WAAW,EAAE,gDAAgD,EAAE;SACzE;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,QAAQ;YACnB,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;YACtC,KAAK,EAAE,EAAE,WAAW,EAAE,mDAAmD,EAAE;SAC5E;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,cAAc;YACzB,QAAQ,EAAE,kBAAkB,CAAC,cAAc,CAAC;YAC5C,KAAK,EAAE,EAAE,WAAW,EAAE,wDAAwD,EAAE;SACjF;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,SAAS;SACtB;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,UAAU;YAChB,YAAY,EAAE,KAAK;YACnB,KAAK,EAAE,EAAE,WAAW,EAAE,8CAA8C,EAAE;SACvE;QACD;YACE,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,UAAU;YAChB,YAAY,EAAE,KAAK;YACnB,KAAK,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE;SACzE;KACF,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,aAAa,CAAC,UAA4B,EAAE;IAC1D,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK;QAChC,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC;KAC3B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,aAAa,GAEd,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zedtech/zedkit-payload-seo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"description": "Localized Payload SEO group field with length validation.",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/zedtech-fr/zedkit",
|
|
13
|
+
"directory": "packages/payload-seo"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"imports": {
|
|
18
|
+
"#*": "./src/*"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"payload": "3.92.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"payload": "3.92.0",
|
|
37
|
+
"typescript": "5.9.3",
|
|
38
|
+
"vitest": "2.1.9"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsc -p tsconfig.json",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"typecheck": "tsc --noEmit -p tsconfig.tests.json",
|
|
44
|
+
"lint": "eslint src tests"
|
|
45
|
+
}
|
|
6
46
|
}
|