nuxtseo-shared 0.1.3 → 0.1.5
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/dist/content.d.mts +14 -21
- package/dist/content.mjs +3 -4
- package/dist/layer-devtools/nuxt.config.ts +5 -1
- package/package.json +2 -2
package/dist/content.d.mts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
1
|
//#region src/content.d.ts
|
|
4
|
-
type ZodInstance = typeof z;
|
|
5
|
-
type ZodTypeAny = z.ZodTypeAny;
|
|
6
2
|
interface ContentSchemaOptions {
|
|
7
3
|
/**
|
|
8
4
|
* Pass the `z` instance from `@nuxt/content` to ensure `.editor()` works
|
|
9
5
|
* across Zod versions. When omitted, the module's bundled `z` is used.
|
|
10
6
|
*/
|
|
11
|
-
z?:
|
|
7
|
+
z?: any;
|
|
12
8
|
}
|
|
13
9
|
interface ContentEditorConfig {
|
|
14
10
|
hidden?: boolean;
|
|
@@ -19,13 +15,12 @@ interface ContentEditorConfig {
|
|
|
19
15
|
* Apply Nuxt Content `.editor()` metadata to a zod schema field.
|
|
20
16
|
* No-ops gracefully when `.editor()` is not patched onto ZodType (outside Nuxt Content).
|
|
21
17
|
*/
|
|
22
|
-
declare function withEditor<T
|
|
18
|
+
declare function withEditor<T>(schema: T, config: ContentEditorConfig): T;
|
|
23
19
|
/**
|
|
24
20
|
* Hide a zod schema field from the Nuxt Content / Studio editor.
|
|
25
|
-
* Only use for fields that genuinely don't work in a form (freeform JSON, deeply nested arrays).
|
|
26
21
|
*/
|
|
27
|
-
declare function withEditorHidden<T
|
|
28
|
-
interface DefineContentSchemaConfig<TSchema extends
|
|
22
|
+
declare function withEditorHidden<T>(schema: T): T;
|
|
23
|
+
interface DefineContentSchemaConfig<TSchema = any, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions> {
|
|
29
24
|
/**
|
|
30
25
|
* The field name used in frontmatter (e.g. 'robots', 'sitemap', 'ogImage').
|
|
31
26
|
*/
|
|
@@ -34,7 +29,7 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny> {
|
|
|
34
29
|
* Build the zod schema for this field. Receives the zod instance
|
|
35
30
|
* (either the user's `@nuxt/content` patched version or the module's bundled one).
|
|
36
31
|
*/
|
|
37
|
-
buildSchema: (z:
|
|
32
|
+
buildSchema: (z: any) => TSchema;
|
|
38
33
|
/**
|
|
39
34
|
* Module label for deprecation warnings (e.g. 'robots', 'sitemap').
|
|
40
35
|
*/
|
|
@@ -43,6 +38,11 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny> {
|
|
|
43
38
|
* Documentation URL for migration guidance.
|
|
44
39
|
*/
|
|
45
40
|
docsUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Hook called when `defineSchema()` is invoked. Use for validation or
|
|
43
|
+
* registering module-specific side effects (e.g. sitemap filter/onUrl).
|
|
44
|
+
*/
|
|
45
|
+
onDefineSchema?: (options: TDefineOptions) => void;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Factory for creating a module's `define*Schema()` and deprecated `as*Collection()` exports.
|
|
@@ -53,7 +53,6 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny> {
|
|
|
53
53
|
* - Deprecated `asXxxCollection()` wrapper with migration warning
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
|
-
* // In @nuxtjs/robots/content.ts
|
|
57
56
|
* import { z } from 'zod'
|
|
58
57
|
* import { createContentSchemaFactory } from 'nuxtseo-shared/content'
|
|
59
58
|
*
|
|
@@ -61,21 +60,15 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny> {
|
|
|
61
60
|
* fieldName: 'robots',
|
|
62
61
|
* label: 'robots',
|
|
63
62
|
* docsUrl: 'https://nuxtseo.com/robots/guides/content',
|
|
64
|
-
* buildSchema: (z) => z.
|
|
63
|
+
* buildSchema: (z) => z.union([z.string(), z.boolean()]).optional(),
|
|
65
64
|
* }, z)
|
|
66
65
|
*
|
|
67
66
|
* export { defineSchema as defineRobotsSchema, asCollection as asRobotsCollection, schema }
|
|
68
67
|
*/
|
|
69
|
-
declare function createContentSchemaFactory<TSchema extends
|
|
70
|
-
defineSchema: (options?:
|
|
68
|
+
declare function createContentSchemaFactory<TSchema, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions>(config: DefineContentSchemaConfig<TSchema, TDefineOptions>, defaultZ: any): {
|
|
69
|
+
defineSchema: (options?: TDefineOptions) => TSchema;
|
|
71
70
|
asCollection: <T>(collection: any) => T;
|
|
72
|
-
schema:
|
|
73
|
-
[x: string]: TSchema;
|
|
74
|
-
}, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
75
|
-
[x: string]: TSchema;
|
|
76
|
-
}>, any> extends infer T ? { [k in keyof T]: T[k] } : never, z.baseObjectInputType<{
|
|
77
|
-
[x: string]: TSchema;
|
|
78
|
-
}> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1] } : never>;
|
|
71
|
+
schema: any;
|
|
79
72
|
fieldSchema: TSchema;
|
|
80
73
|
};
|
|
81
74
|
//#endregion
|
package/dist/content.mjs
CHANGED
|
@@ -9,7 +9,6 @@ function withEditor(schema, config) {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Hide a zod schema field from the Nuxt Content / Studio editor.
|
|
12
|
-
* Only use for fields that genuinely don't work in a form (freeform JSON, deeply nested arrays).
|
|
13
12
|
*/
|
|
14
13
|
function withEditorHidden(schema) {
|
|
15
14
|
return withEditor(schema, { hidden: true });
|
|
@@ -23,7 +22,6 @@ function withEditorHidden(schema) {
|
|
|
23
22
|
* - Deprecated `asXxxCollection()` wrapper with migration warning
|
|
24
23
|
*
|
|
25
24
|
* @example
|
|
26
|
-
* // In @nuxtjs/robots/content.ts
|
|
27
25
|
* import { z } from 'zod'
|
|
28
26
|
* import { createContentSchemaFactory } from 'nuxtseo-shared/content'
|
|
29
27
|
*
|
|
@@ -31,16 +29,17 @@ function withEditorHidden(schema) {
|
|
|
31
29
|
* fieldName: 'robots',
|
|
32
30
|
* label: 'robots',
|
|
33
31
|
* docsUrl: 'https://nuxtseo.com/robots/guides/content',
|
|
34
|
-
* buildSchema: (z) => z.
|
|
32
|
+
* buildSchema: (z) => z.union([z.string(), z.boolean()]).optional(),
|
|
35
33
|
* }, z)
|
|
36
34
|
*
|
|
37
35
|
* export { defineSchema as defineRobotsSchema, asCollection as asRobotsCollection, schema }
|
|
38
36
|
*/
|
|
39
37
|
function createContentSchemaFactory(config, defaultZ) {
|
|
40
|
-
const { fieldName, buildSchema, label, docsUrl } = config;
|
|
38
|
+
const { fieldName, buildSchema, label, docsUrl, onDefineSchema } = config;
|
|
41
39
|
const defaultSchema = buildSchema(defaultZ);
|
|
42
40
|
const schemaObject = defaultZ.object({ [fieldName]: defaultSchema });
|
|
43
41
|
function defineSchema(options) {
|
|
42
|
+
if (options && onDefineSchema) onDefineSchema(options);
|
|
44
43
|
const _z = options?.z ?? defaultZ;
|
|
45
44
|
if (_z === defaultZ) return defaultSchema;
|
|
46
45
|
return buildSchema(_z);
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createResolver } from '@nuxt/kit'
|
|
2
|
+
|
|
3
|
+
const { resolve } = createResolver(import.meta.url)
|
|
4
|
+
|
|
1
5
|
export default defineNuxtConfig({
|
|
2
6
|
ssr: false,
|
|
3
7
|
|
|
@@ -6,7 +10,7 @@ export default defineNuxtConfig({
|
|
|
6
10
|
'@nuxt/ui',
|
|
7
11
|
],
|
|
8
12
|
|
|
9
|
-
css: ['./assets/css/global.css'],
|
|
13
|
+
css: [resolve('./assets/css/global.css')],
|
|
10
14
|
|
|
11
15
|
fonts: {
|
|
12
16
|
families: [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxtseo-shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"description": "Shared utilities for Nuxt SEO modules.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"nuxt": "^3.16.0 || ^4.0.0",
|
|
51
51
|
"nuxt-site-config": "^3.2.0",
|
|
52
52
|
"vue": "^3.5.0",
|
|
53
|
-
"zod": "^3.23.0"
|
|
53
|
+
"zod": "^3.23.0 || ^4.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependenciesMeta": {
|
|
56
56
|
"nuxt-site-config": {
|