sanity-plugin-seofields 1.6.4 → 1.6.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/{SeoPreview-XVAZYHCL.js → SeoPreview-KEGGQSPJ.js} +5 -4
- package/dist/{SeoPreview-PYYVZMY3.cjs.map → SeoPreview-KEGGQSPJ.js.map} +1 -1
- package/dist/{SeoPreview-PYYVZMY3.cjs → SeoPreview-WYH7NYNM.cjs} +6 -5
- package/dist/SeoPreview-WYH7NYNM.cjs.map +1 -0
- package/dist/{chunk-25JLWVEU.js → chunk-HDZZQCH7.js} +14 -8
- package/dist/chunk-HDZZQCH7.js.map +1 -0
- package/dist/{chunk-IFDLKZET.cjs → chunk-ZBHLMQTS.cjs} +14 -8
- package/dist/chunk-ZBHLMQTS.cjs.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.cjs +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/SeoPreview-XVAZYHCL.js.map +0 -1
- package/dist/chunk-25JLWVEU.js.map +0 -1
- package/dist/chunk-IFDLKZET.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var chunkZBHLMQTS_cjs = require('./chunk-ZBHLMQTS.cjs');
|
|
6
6
|
var chunkS367Y35J_cjs = require('./chunk-S367Y35J.cjs');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var sanity = require('sanity');
|
|
@@ -15,7 +15,7 @@ var MetaDescription = (props) => {
|
|
|
15
15
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
16
16
|
const keywords = react.useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
17
17
|
const feedbackItems = react.useMemo(
|
|
18
|
-
() =>
|
|
18
|
+
() => chunkZBHLMQTS_cjs.getMetaDescriptionValidationMessages(value || "", keywords, isParentseoField),
|
|
19
19
|
[value, keywords, isParentseoField]
|
|
20
20
|
);
|
|
21
21
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -37,7 +37,7 @@ var MetaImage = (props) => {
|
|
|
37
37
|
const seoParent = sanity.useFormValue([path[0]]);
|
|
38
38
|
const hasImage = !!(value == null ? void 0 : value.asset);
|
|
39
39
|
const feedbackItems = react.useMemo(
|
|
40
|
-
() =>
|
|
40
|
+
() => chunkZBHLMQTS_cjs.getMetaImageValidation(hasImage, seoParent),
|
|
41
41
|
[hasImage, seoParent]
|
|
42
42
|
);
|
|
43
43
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -60,13 +60,37 @@ var MetaImage = (props) => {
|
|
|
60
60
|
};
|
|
61
61
|
var MetaImage_default = MetaImage;
|
|
62
62
|
var MetaTitle = (props) => {
|
|
63
|
-
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const { value, renderDefault, path, schemaType } = props;
|
|
65
|
+
const { options } = schemaType;
|
|
64
66
|
const parent = sanity.useFormValue([path[0]]);
|
|
65
67
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
66
68
|
const keywords = react.useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
69
|
+
const rootDoc = (_a = sanity.useFormValue([])) != null ? _a : {};
|
|
70
|
+
const client = sanity.useClient({ apiVersion: (_b = options == null ? void 0 : options.apiVersion) != null ? _b : "2024-01-01" });
|
|
71
|
+
const [groqTitleSuffix, setGroqTitleSuffix] = react.useState("");
|
|
72
|
+
const titleSuffixQuery = options == null ? void 0 : options.titleSuffixQuery;
|
|
73
|
+
const titleSuffixOption = options == null ? void 0 : options.titleSuffix;
|
|
74
|
+
react.useEffect(() => {
|
|
75
|
+
if (!titleSuffixQuery) return;
|
|
76
|
+
client.fetch(titleSuffixQuery).then((result) => {
|
|
77
|
+
setGroqTitleSuffix(result === null || result === void 0 ? "" : String(result));
|
|
78
|
+
}).catch(() => {
|
|
79
|
+
setGroqTitleSuffix("");
|
|
80
|
+
});
|
|
81
|
+
}, [titleSuffixQuery, client]);
|
|
82
|
+
const resolvedSuffix = react.useMemo(() => {
|
|
83
|
+
if (titleSuffixQuery) return groqTitleSuffix;
|
|
84
|
+
if (!titleSuffixOption) return "";
|
|
85
|
+
if (typeof titleSuffixOption === "function") {
|
|
86
|
+
return titleSuffixOption(rootDoc);
|
|
87
|
+
}
|
|
88
|
+
return titleSuffixOption;
|
|
89
|
+
}, [titleSuffixQuery, groqTitleSuffix, titleSuffixOption, rootDoc]);
|
|
90
|
+
const suffixLength = resolvedSuffix ? resolvedSuffix.length + 3 : 0;
|
|
67
91
|
const feedbackItems = react.useMemo(
|
|
68
|
-
() =>
|
|
69
|
-
[value, keywords, isParentseoField]
|
|
92
|
+
() => chunkZBHLMQTS_cjs.getMetaTitleValidationMessages(value || "", keywords, isParentseoField, suffixLength),
|
|
93
|
+
[value, keywords, isParentseoField, suffixLength]
|
|
70
94
|
);
|
|
71
95
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
72
96
|
renderDefault(props),
|
|
@@ -216,7 +240,7 @@ var OgDescription = (props) => {
|
|
|
216
240
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
217
241
|
const keywords = react.useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
218
242
|
const feedbackItems = react.useMemo(
|
|
219
|
-
() =>
|
|
243
|
+
() => chunkZBHLMQTS_cjs.getOgDescriptionValidation(value || "", keywords, isParentseoField),
|
|
220
244
|
[value, keywords, isParentseoField]
|
|
221
245
|
);
|
|
222
246
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -245,7 +269,7 @@ var OgImage = (props) => {
|
|
|
245
269
|
const hasImage = !!(imgValue == null ? void 0 : imgValue.asset);
|
|
246
270
|
const altText = imgValue == null ? void 0 : imgValue.alt;
|
|
247
271
|
const feedbackItems = react.useMemo(
|
|
248
|
-
() =>
|
|
272
|
+
() => chunkZBHLMQTS_cjs.getOgImageValidation(hasImage, altText, seoParent),
|
|
249
273
|
[hasImage, altText, seoParent]
|
|
250
274
|
);
|
|
251
275
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -270,7 +294,7 @@ var OgImage_default = OgImage;
|
|
|
270
294
|
var OgImageUrl = (props) => {
|
|
271
295
|
const { value, renderDefault, path } = props;
|
|
272
296
|
const seoParent = sanity.useFormValue([path[0]]);
|
|
273
|
-
const feedbackItems = react.useMemo(() =>
|
|
297
|
+
const feedbackItems = react.useMemo(() => chunkZBHLMQTS_cjs.getOgImageUrlValidation(value, seoParent), [value, seoParent]);
|
|
274
298
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
275
299
|
renderDefault(props),
|
|
276
300
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: feedbackItems.map((item) => /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 7 }, children: [
|
|
@@ -296,7 +320,7 @@ var OgTitle = (props) => {
|
|
|
296
320
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
297
321
|
const keywords = react.useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
298
322
|
const feedbackItems = react.useMemo(
|
|
299
|
-
() =>
|
|
323
|
+
() => chunkZBHLMQTS_cjs.getOgTitleValidation(value || "", keywords, isParentseoField),
|
|
300
324
|
[value, keywords, isParentseoField]
|
|
301
325
|
);
|
|
302
326
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -440,7 +464,7 @@ var TwitterDescription = (props) => {
|
|
|
440
464
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
441
465
|
const keywords = react.useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
442
466
|
const feedbackItems = react.useMemo(
|
|
443
|
-
() =>
|
|
467
|
+
() => chunkZBHLMQTS_cjs.getTwitterDescriptionValidation(value || "", keywords, isParentseoField),
|
|
444
468
|
[value, keywords, isParentseoField]
|
|
445
469
|
);
|
|
446
470
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -469,7 +493,7 @@ var TwitterImage = (props) => {
|
|
|
469
493
|
const hasImage = !!(imgValue == null ? void 0 : imgValue.asset);
|
|
470
494
|
const altText = imgValue == null ? void 0 : imgValue.alt;
|
|
471
495
|
const feedbackItems = react.useMemo(
|
|
472
|
-
() =>
|
|
496
|
+
() => chunkZBHLMQTS_cjs.getTwitterImageValidation(hasImage, altText, seoParent),
|
|
473
497
|
[hasImage, altText, seoParent]
|
|
474
498
|
);
|
|
475
499
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -495,7 +519,7 @@ var TwitterImageUrl = (props) => {
|
|
|
495
519
|
const { value, renderDefault, path } = props;
|
|
496
520
|
const seoParent = sanity.useFormValue([path[0]]);
|
|
497
521
|
const feedbackItems = react.useMemo(
|
|
498
|
-
() =>
|
|
522
|
+
() => chunkZBHLMQTS_cjs.getTwitterImageUrlValidation(value, seoParent),
|
|
499
523
|
[value, seoParent]
|
|
500
524
|
);
|
|
501
525
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -523,7 +547,7 @@ var TwitterTitle = (props) => {
|
|
|
523
547
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
524
548
|
const keywords = react.useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
525
549
|
const feedbackItems = react.useMemo(
|
|
526
|
-
() =>
|
|
550
|
+
() => chunkZBHLMQTS_cjs.getTwitterTitleValidation(value || "", keywords, isParentseoField),
|
|
527
551
|
[value, keywords, isParentseoField]
|
|
528
552
|
);
|
|
529
553
|
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
@@ -657,7 +681,7 @@ function twitter(config = {}) {
|
|
|
657
681
|
}
|
|
658
682
|
|
|
659
683
|
// src/schemas/index.ts
|
|
660
|
-
var LazySeoPreview = react.lazy(() => import('./SeoPreview-
|
|
684
|
+
var LazySeoPreview = react.lazy(() => import('./SeoPreview-WYH7NYNM.cjs'));
|
|
661
685
|
var SeoPreviewWrapper = (props) => react.createElement(react.Suspense, { fallback: null }, react.createElement(LazySeoPreview, props));
|
|
662
686
|
function buildFieldGroupMap(groups) {
|
|
663
687
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -736,6 +760,7 @@ function seoFieldsSchema(config = {}) {
|
|
|
736
760
|
components: {
|
|
737
761
|
input: MetaTitle_default
|
|
738
762
|
},
|
|
763
|
+
options: chunkS367Y35J_cjs.__spreadValues(chunkS367Y35J_cjs.__spreadValues(chunkS367Y35J_cjs.__spreadValues({}, config.apiVersion ? { apiVersion: config.apiVersion } : {}), typeof config.seoPreview === "object" && config.seoPreview && config.seoPreview.titleSuffix ? { titleSuffix: config.seoPreview.titleSuffix } : {}), typeof config.seoPreview === "object" && config.seoPreview && config.seoPreview.titleSuffixQuery ? { titleSuffixQuery: config.seoPreview.titleSuffixQuery } : {}),
|
|
739
764
|
hidden: getFieldHiddenFunction("title", config)
|
|
740
765
|
})),
|
|
741
766
|
fieldGroupMap
|