sanity-plugin-seofields 1.6.3 → 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-XXQURVNE.cjs → chunk-BCTPOWXA.cjs} +111 -111
- package/dist/{chunk-XXQURVNE.cjs.map → chunk-BCTPOWXA.cjs.map} +1 -1
- package/dist/{chunk-25JLWVEU.js → chunk-HDZZQCH7.js} +14 -8
- package/dist/chunk-HDZZQCH7.js.map +1 -0
- package/dist/{chunk-IQG5JWVT.js → chunk-KTL6NYNG.js} +4 -2
- package/dist/chunk-KTL6NYNG.js.map +1 -0
- package/dist/{chunk-ULFY5STC.js → chunk-XXA6WCWS.js} +3 -3
- package/dist/{chunk-ULFY5STC.js.map → chunk-XXA6WCWS.js.map} +1 -1
- package/dist/{chunk-YM3ZZ2HU.cjs → chunk-YHXUWGNA.cjs} +4 -2
- package/dist/chunk-YHXUWGNA.cjs.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/{component-DS-Ve_nw.d.cts → component-CIE6Sy4F.d.cts} +1 -1
- package/dist/{component-CWZ0tlsq.d.ts → component-H52blyfc.d.ts} +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/dist/next.cjs +77 -77
- package/dist/next.d.cts +2 -2
- package/dist/next.d.ts +2 -2
- package/dist/next.js +2 -2
- package/dist/schema/next.cjs +80 -80
- package/dist/schema/next.d.cts +3 -3
- package/dist/schema/next.d.ts +3 -3
- package/dist/schema/next.js +3 -3
- package/dist/schema.cjs +153 -153
- package/dist/schema.d.cts +4 -4
- package/dist/schema.d.ts +4 -4
- package/dist/schema.js +2 -2
- package/dist/{types-BdaGoGQE.d.cts → types-BxcJinOf.d.cts} +8 -8
- package/dist/{types-Dy7r5det.d.ts → types-CbYb4MsN.d.ts} +1 -1
- package/dist/{types-BjVpmBAX.d.cts → types-CyRdIF-3.d.cts} +1 -1
- package/dist/{types-BwmZmt9I.d.ts → types-Dp9Pfnt9.d.ts} +8 -8
- 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/chunk-IQG5JWVT.js.map +0 -1
- package/dist/chunk-YM3ZZ2HU.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getMetaTitleValidationMessages, getMetaDescriptionValidationMessages, getMetaImageValidation, getOgTitleValidation, getOgDescriptionValidation, getOgImageValidation, getOgImageUrlValidation, getTwitterTitleValidation, getTwitterDescriptionValidation, getTwitterImageValidation, getTwitterImageUrlValidation } from './chunk-
|
|
1
|
+
import { getMetaTitleValidationMessages, getMetaDescriptionValidationMessages, getMetaImageValidation, getOgTitleValidation, getOgDescriptionValidation, getOgImageValidation, getOgImageUrlValidation, getTwitterTitleValidation, getTwitterDescriptionValidation, getTwitterImageValidation, getTwitterImageUrlValidation } from './chunk-HDZZQCH7.js';
|
|
2
2
|
import { __spreadValues, __spreadProps, __objRest } from './chunk-2NMEKWO5.js';
|
|
3
|
-
import { lazy, createElement, Suspense, useMemo } from 'react';
|
|
4
|
-
import { defineType, defineField, definePlugin, useFormValue } from 'sanity';
|
|
3
|
+
import { lazy, createElement, Suspense, useMemo, useState, useEffect } from 'react';
|
|
4
|
+
import { defineType, defineField, definePlugin, useFormValue, useClient } from 'sanity';
|
|
5
5
|
import { Stack, Text } from '@sanity/ui';
|
|
6
6
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -56,13 +56,37 @@ var MetaImage = (props) => {
|
|
|
56
56
|
};
|
|
57
57
|
var MetaImage_default = MetaImage;
|
|
58
58
|
var MetaTitle = (props) => {
|
|
59
|
-
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const { value, renderDefault, path, schemaType } = props;
|
|
61
|
+
const { options } = schemaType;
|
|
60
62
|
const parent = useFormValue([path[0]]);
|
|
61
63
|
const isParentseoField = parent && (parent == null ? void 0 : parent._type) === "seoFields";
|
|
62
64
|
const keywords = useMemo(() => (parent == null ? void 0 : parent.keywords) || [], [parent == null ? void 0 : parent.keywords]);
|
|
65
|
+
const rootDoc = (_a = useFormValue([])) != null ? _a : {};
|
|
66
|
+
const client = useClient({ apiVersion: (_b = options == null ? void 0 : options.apiVersion) != null ? _b : "2024-01-01" });
|
|
67
|
+
const [groqTitleSuffix, setGroqTitleSuffix] = useState("");
|
|
68
|
+
const titleSuffixQuery = options == null ? void 0 : options.titleSuffixQuery;
|
|
69
|
+
const titleSuffixOption = options == null ? void 0 : options.titleSuffix;
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!titleSuffixQuery) return;
|
|
72
|
+
client.fetch(titleSuffixQuery).then((result) => {
|
|
73
|
+
setGroqTitleSuffix(result === null || result === void 0 ? "" : String(result));
|
|
74
|
+
}).catch(() => {
|
|
75
|
+
setGroqTitleSuffix("");
|
|
76
|
+
});
|
|
77
|
+
}, [titleSuffixQuery, client]);
|
|
78
|
+
const resolvedSuffix = useMemo(() => {
|
|
79
|
+
if (titleSuffixQuery) return groqTitleSuffix;
|
|
80
|
+
if (!titleSuffixOption) return "";
|
|
81
|
+
if (typeof titleSuffixOption === "function") {
|
|
82
|
+
return titleSuffixOption(rootDoc);
|
|
83
|
+
}
|
|
84
|
+
return titleSuffixOption;
|
|
85
|
+
}, [titleSuffixQuery, groqTitleSuffix, titleSuffixOption, rootDoc]);
|
|
86
|
+
const suffixLength = resolvedSuffix ? resolvedSuffix.length + 3 : 0;
|
|
63
87
|
const feedbackItems = useMemo(
|
|
64
|
-
() => getMetaTitleValidationMessages(value || "", keywords, isParentseoField),
|
|
65
|
-
[value, keywords, isParentseoField]
|
|
88
|
+
() => getMetaTitleValidationMessages(value || "", keywords, isParentseoField, suffixLength),
|
|
89
|
+
[value, keywords, isParentseoField, suffixLength]
|
|
66
90
|
);
|
|
67
91
|
return /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
68
92
|
renderDefault(props),
|
|
@@ -653,7 +677,7 @@ function twitter(config = {}) {
|
|
|
653
677
|
}
|
|
654
678
|
|
|
655
679
|
// src/schemas/index.ts
|
|
656
|
-
var LazySeoPreview = lazy(() => import('./SeoPreview-
|
|
680
|
+
var LazySeoPreview = lazy(() => import('./SeoPreview-KEGGQSPJ.js'));
|
|
657
681
|
var SeoPreviewWrapper = (props) => createElement(Suspense, { fallback: null }, createElement(LazySeoPreview, props));
|
|
658
682
|
function buildFieldGroupMap(groups) {
|
|
659
683
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -732,6 +756,7 @@ function seoFieldsSchema(config = {}) {
|
|
|
732
756
|
components: {
|
|
733
757
|
input: MetaTitle_default
|
|
734
758
|
},
|
|
759
|
+
options: __spreadValues(__spreadValues(__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 } : {}),
|
|
735
760
|
hidden: getFieldHiddenFunction("title", config)
|
|
736
761
|
})),
|
|
737
762
|
fieldGroupMap
|