sanity-plugin-seofields 1.7.0 → 1.8.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/README.md +3 -3
- package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.cts +78 -0
- package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.ts +78 -0
- package/dist/SeoHealthDashboard-AEKVVMUR-7NWV3C3Y.js +4 -0
- package/dist/SeoHealthDashboard-AEKVVMUR-7NWV3C3Y.js.map +1 -0
- package/dist/SeoHealthDashboard-AEKVVMUR-XWKJUH24.cjs +10 -0
- package/dist/SeoHealthDashboard-AEKVVMUR-XWKJUH24.cjs.map +1 -0
- package/dist/SeoHealthTool-2KKQJLJL.cjs +11 -0
- package/dist/{SeoHealthDashboard-PTUEVYZL.js.map → SeoHealthTool-2KKQJLJL.cjs.map} +1 -1
- package/dist/SeoHealthTool-3CUKGADZ.js +5 -0
- package/dist/{SeoHealthDashboard-IP5BJ322.cjs.map → SeoHealthTool-3CUKGADZ.js.map} +1 -1
- package/dist/{SeoPreview-WYH7NYNM.cjs → SeoPreview-3EXR6FD4.cjs} +3 -3
- package/dist/{SeoPreview-WYH7NYNM.cjs.map → SeoPreview-3EXR6FD4.cjs.map} +1 -1
- package/dist/{SeoPreview-KEGGQSPJ.js → SeoPreview-4PPAF4NO.js} +3 -3
- package/dist/{SeoPreview-KEGGQSPJ.js.map → SeoPreview-4PPAF4NO.js.map} +1 -1
- package/dist/{chunk-S367Y35J.cjs → chunk-254YHUN3.cjs} +2 -15
- package/dist/{chunk-S367Y35J.cjs.map → chunk-254YHUN3.cjs.map} +1 -1
- package/dist/{chunk-AW7OKBQQ.js → chunk-27XSYENH.js} +59 -5
- package/dist/chunk-27XSYENH.js.map +1 -0
- package/dist/{chunk-GWPOJSGW.cjs → chunk-B5IVI5LP.cjs} +821 -156
- package/dist/chunk-B5IVI5LP.cjs.map +1 -0
- package/dist/chunk-BNXMFD3T.cjs +431 -0
- package/dist/chunk-BNXMFD3T.cjs.map +1 -0
- package/dist/{chunk-2NMEKWO5.js → chunk-DDAAVRWG.js} +3 -15
- package/dist/{chunk-2NMEKWO5.js.map → chunk-DDAAVRWG.js.map} +1 -1
- package/dist/chunk-P6IOWIO2.cjs +480 -0
- package/dist/chunk-P6IOWIO2.cjs.map +1 -0
- package/dist/{chunk-FONJYVF2.js → chunk-UOCZFYYP.js} +5 -208
- package/dist/chunk-UOCZFYYP.js.map +1 -0
- package/dist/{chunk-HRKRV2X7.js → chunk-VR44E62I.js} +802 -147
- package/dist/chunk-VR44E62I.js.map +1 -0
- package/dist/chunk-WKXHX3GO.js +424 -0
- package/dist/chunk-WKXHX3GO.js.map +1 -0
- package/dist/{chunk-5YRH47VQ.cjs → chunk-XZDLJ2N6.cjs} +63 -6
- package/dist/chunk-XZDLJ2N6.cjs.map +1 -0
- package/dist/cli.js +18 -18
- package/dist/{component-DQ4KuQQD.d.ts → component-BzI-LHPw.d.cts} +3 -27
- package/dist/{component-D1sBm6ts.d.cts → component-DEXwtemT.d.ts} +3 -27
- package/dist/define-cli.cjs +1 -1
- package/dist/define-cli.js +1 -1
- package/dist/index.cjs +1050 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -295
- package/dist/index.d.ts +76 -295
- package/dist/index.js +1009 -63
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +136 -122
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +9 -3
- package/dist/next.d.ts +9 -3
- package/dist/next.js +38 -32
- package/dist/next.js.map +1 -1
- package/dist/schema/next.cjs +103 -95
- package/dist/schema/next.d.cts +4 -4
- package/dist/schema/next.d.ts +4 -4
- package/dist/schema/next.js +4 -4
- package/dist/schema.cjs +202 -160
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.d.cts +26 -16
- package/dist/schema.d.ts +26 -16
- package/dist/schema.js +25 -7
- package/dist/schema.js.map +1 -1
- package/dist/{types-9_wbCIi9.d.ts → types-BXSCbl6p.d.cts} +29 -2
- package/dist/{types-_wBLg6RV.d.cts → types-B_vjMPtM.d.cts} +1 -1
- package/dist/{types-Bb49oRBV.d.cts → types-C19cQx5D.d.ts} +29 -2
- package/dist/{types-CeBULNFF.d.ts → types-CW8qFdAn.d.ts} +1 -1
- package/dist/{types-B91ena4g.d.cts → types-yVmQfby9.d.cts} +7 -0
- package/dist/{types-B91ena4g.d.ts → types-yVmQfby9.d.ts} +7 -0
- package/package.json +2 -1
- package/dist/SeoHealthDashboard-IP5BJ322.cjs +0 -10
- package/dist/SeoHealthDashboard-PTUEVYZL.js +0 -4
- package/dist/SeoHealthTool-CZZRMWQK.cjs +0 -14
- package/dist/SeoHealthTool-CZZRMWQK.cjs.map +0 -1
- package/dist/SeoHealthTool-IULT4G25.js +0 -12
- package/dist/SeoHealthTool-IULT4G25.js.map +0 -1
- package/dist/chunk-5YRH47VQ.cjs.map +0 -1
- package/dist/chunk-ARELX3GK.cjs +0 -689
- package/dist/chunk-ARELX3GK.cjs.map +0 -1
- package/dist/chunk-AW7OKBQQ.js.map +0 -1
- package/dist/chunk-FONJYVF2.js.map +0 -1
- package/dist/chunk-GWPOJSGW.cjs.map +0 -1
- package/dist/chunk-HRKRV2X7.js.map +0 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { __spreadValues, __spreadProps } from './chunk-
|
|
2
|
-
import { defineType, defineField } from 'sanity';
|
|
1
|
+
import { __spreadValues, __spreadProps } from './chunk-DDAAVRWG.js';
|
|
2
|
+
import { useColorScheme, useClient, useFormValue, defineType, defineField } from 'sanity';
|
|
3
|
+
import { Card, Stack, Flex, Text, Box } from '@sanity/ui';
|
|
4
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
3
5
|
import { PackageIcon, PlayIcon, UserIcon, ListIcon, DocumentTextIcon, BookIcon, HomeIcon, ClipboardIcon, EarthGlobeIcon, MasterDetailIcon, DesktopIcon, CodeBlockIcon, ApiIcon, CalendarIcon, MarkerIcon, RobotIcon, HeartFilledIcon, BarChartIcon, TagIcon, CommentIcon, HelpCircleIcon, VideoIcon, ImageIcon, LinkIcon, SparkleIcon, ComponentIcon } from '@sanity/icons';
|
|
6
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
7
|
|
|
5
8
|
// src/schema/_shared.ts
|
|
6
9
|
var imageObjectInnerFields = [
|
|
@@ -1098,148 +1101,8 @@ function licenseUrlField(opts = {}) {
|
|
|
1098
1101
|
urlValidation: { schemes: ["http", "https"] }
|
|
1099
1102
|
}, opts.required ? { required: opts.required } : {});
|
|
1100
1103
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
if (fieldDef.type === "select" && ((_a = fieldDef.variants) == null ? void 0 : _a.length)) {
|
|
1104
|
-
const variants = fieldDef.variants;
|
|
1105
|
-
const defaultVariant = (_b = fieldDef.defaultVariant) != null ? _b : variants[0].value;
|
|
1106
|
-
const innerFields = [
|
|
1107
|
-
{
|
|
1108
|
-
name: "variant",
|
|
1109
|
-
title: "Type",
|
|
1110
|
-
type: "string",
|
|
1111
|
-
description: "Choose how to provide this value.",
|
|
1112
|
-
initialValue: defaultVariant,
|
|
1113
|
-
options: variants.map((v) => ({ title: v.title, value: v.value })),
|
|
1114
|
-
layout: "radio"
|
|
1115
|
-
},
|
|
1116
|
-
...variants.map((v) => {
|
|
1117
|
-
if (v.fields.length === 1 && v.fields[0].name === v.value) {
|
|
1118
|
-
return v.fields[0];
|
|
1119
|
-
}
|
|
1120
|
-
return {
|
|
1121
|
-
name: v.value,
|
|
1122
|
-
title: v.title,
|
|
1123
|
-
type: "object",
|
|
1124
|
-
jsonLdType: v.jsonLdType,
|
|
1125
|
-
fields: v.fields
|
|
1126
|
-
};
|
|
1127
|
-
})
|
|
1128
|
-
];
|
|
1129
|
-
const base2 = {
|
|
1130
|
-
name: fieldDef.name,
|
|
1131
|
-
title: fieldDef.title,
|
|
1132
|
-
type: "object",
|
|
1133
|
-
fields: innerFields.map((child) => {
|
|
1134
|
-
const built = buildField(child, validation);
|
|
1135
|
-
if (child.name !== "variant") {
|
|
1136
|
-
const dv = defaultVariant;
|
|
1137
|
-
built.hidden = ({ parent }) => {
|
|
1138
|
-
var _a2;
|
|
1139
|
-
return ((_a2 = parent == null ? void 0 : parent.variant) != null ? _a2 : dv) !== child.name;
|
|
1140
|
-
};
|
|
1141
|
-
}
|
|
1142
|
-
return built;
|
|
1143
|
-
})
|
|
1144
|
-
};
|
|
1145
|
-
if (fieldDef.description) base2.description = fieldDef.description;
|
|
1146
|
-
return defineField(base2);
|
|
1147
|
-
}
|
|
1148
|
-
if (fieldDef.type === "copyrightYear") {
|
|
1149
|
-
const base2 = {
|
|
1150
|
-
name: fieldDef.name,
|
|
1151
|
-
title: fieldDef.title,
|
|
1152
|
-
type: "object",
|
|
1153
|
-
description: (_c = fieldDef.description) != null ? _c : 'Copyright year. Toggle "Use current year" to emit the current year dynamically.',
|
|
1154
|
-
fields: [
|
|
1155
|
-
defineField({
|
|
1156
|
-
name: "useDynamicYear",
|
|
1157
|
-
title: "Use current year (dynamic)",
|
|
1158
|
-
type: "boolean",
|
|
1159
|
-
initialValue: false
|
|
1160
|
-
}),
|
|
1161
|
-
defineField({
|
|
1162
|
-
name: "year",
|
|
1163
|
-
title: "Static year",
|
|
1164
|
-
type: "number",
|
|
1165
|
-
hidden: ({ parent }) => (parent == null ? void 0 : parent.useDynamicYear) === true
|
|
1166
|
-
})
|
|
1167
|
-
]
|
|
1168
|
-
};
|
|
1169
|
-
return defineField(base2);
|
|
1170
|
-
}
|
|
1171
|
-
const base = {
|
|
1172
|
-
name: fieldDef.name,
|
|
1173
|
-
title: fieldDef.title,
|
|
1174
|
-
type: fieldDef.type
|
|
1175
|
-
};
|
|
1176
|
-
if (fieldDef.description) base.description = fieldDef.description;
|
|
1177
|
-
if (fieldDef.initialValue !== void 0) base.initialValue = fieldDef.initialValue;
|
|
1178
|
-
if (fieldDef.rows) base.rows = fieldDef.rows;
|
|
1179
|
-
if (fieldDef.options) {
|
|
1180
|
-
base.options = __spreadValues({ list: fieldDef.options }, fieldDef.layout && { layout: fieldDef.layout });
|
|
1181
|
-
}
|
|
1182
|
-
if (fieldDef.type === "array" && ((_d = fieldDef.fields) == null ? void 0 : _d.length) && !fieldDef.of) {
|
|
1183
|
-
base.of = [
|
|
1184
|
-
{
|
|
1185
|
-
type: "object",
|
|
1186
|
-
fields: fieldDef.fields.map((child) => buildField(child, validation))
|
|
1187
|
-
}
|
|
1188
|
-
];
|
|
1189
|
-
} else if (fieldDef.of) {
|
|
1190
|
-
base.of = fieldDef.of;
|
|
1191
|
-
}
|
|
1192
|
-
if (fieldDef.type !== "array" && ((_e = fieldDef.fields) == null ? void 0 : _e.length)) {
|
|
1193
|
-
base.fields = fieldDef.fields.map((child) => buildField(child, validation));
|
|
1194
|
-
}
|
|
1195
|
-
if (fieldDef.type === "url" && (fieldDef.required || fieldDef.urlValidation)) {
|
|
1196
|
-
const required = fieldDef.required;
|
|
1197
|
-
const requiredMsg = required ? (_f = validation == null ? void 0 : validation[required.key]) != null ? _f : required.message : void 0;
|
|
1198
|
-
const schemes = (_h = (_g = fieldDef.urlValidation) == null ? void 0 : _g.schemes) != null ? _h : ["http", "https"];
|
|
1199
|
-
const allowRelative = (_j = (_i = fieldDef.urlValidation) == null ? void 0 : _i.allowRelative) != null ? _j : false;
|
|
1200
|
-
base.validation = (Rule) => {
|
|
1201
|
-
const checks = [];
|
|
1202
|
-
if (requiredMsg) checks.push(Rule.required().error(requiredMsg));
|
|
1203
|
-
checks.push(
|
|
1204
|
-
Rule.uri({ scheme: schemes, allowRelative }).error(
|
|
1205
|
-
`Must be a valid URL (${schemes.join(", ")}).`
|
|
1206
|
-
)
|
|
1207
|
-
);
|
|
1208
|
-
return checks;
|
|
1209
|
-
};
|
|
1210
|
-
} else if (fieldDef.required) {
|
|
1211
|
-
const msg = (_k = validation == null ? void 0 : validation[fieldDef.required.key]) != null ? _k : fieldDef.required.message;
|
|
1212
|
-
base.validation = (Rule) => Rule.required().error(msg);
|
|
1213
|
-
}
|
|
1214
|
-
return defineField(base);
|
|
1215
|
-
}
|
|
1216
|
-
function mapNameToSameValue(...items) {
|
|
1217
|
-
return items.reduce(
|
|
1218
|
-
(acc, item) => {
|
|
1219
|
-
acc[item.name] = item.name;
|
|
1220
|
-
return acc;
|
|
1221
|
-
},
|
|
1222
|
-
{}
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
|
-
function generateSchemaType(def, config = {}) {
|
|
1226
|
-
return defineType(__spreadProps(__spreadValues({
|
|
1227
|
-
name: def.name,
|
|
1228
|
-
title: def.title,
|
|
1229
|
-
type: "object"
|
|
1230
|
-
}, def.icon && { icon: def.icon }), {
|
|
1231
|
-
fields: def.fields.map((f) => buildField(f, config.validation)),
|
|
1232
|
-
preview: {
|
|
1233
|
-
select: mapNameToSameValue(...def.fields),
|
|
1234
|
-
prepare(selection) {
|
|
1235
|
-
return __spreadValues({
|
|
1236
|
-
title: def.title,
|
|
1237
|
-
subtitle: (def == null ? void 0 : def.customPrepareSubtitle) ? def.customPrepareSubtitle(selection) : `@type: ${def.title}`
|
|
1238
|
-
}, def.icon && { media: def.icon });
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
}));
|
|
1242
|
-
}
|
|
1104
|
+
|
|
1105
|
+
// src/schema/jsonLd.ts
|
|
1243
1106
|
var SANITY_INTERNAL_KEYS = /* @__PURE__ */ new Set([
|
|
1244
1107
|
"_key",
|
|
1245
1108
|
"_type",
|
|
@@ -1338,6 +1201,165 @@ function buildGenericJsonLd(schemaType, data, fieldDefs, requiredFields = []) {
|
|
|
1338
1201
|
"@type": schemaType
|
|
1339
1202
|
}, body);
|
|
1340
1203
|
}
|
|
1204
|
+
|
|
1205
|
+
// src/utils/syntaxHighlight.ts
|
|
1206
|
+
var LIGHT = {
|
|
1207
|
+
default: "#24292f",
|
|
1208
|
+
punctuation: "#57606a",
|
|
1209
|
+
tag: "#1a7f37",
|
|
1210
|
+
// HTML tag names — vivid green
|
|
1211
|
+
attr: "#8250df",
|
|
1212
|
+
// HTML attribute names / JSON keys — vivid purple
|
|
1213
|
+
string: "#cf222e",
|
|
1214
|
+
// Attribute values / JSON string values — vivid red
|
|
1215
|
+
number: "#953800",
|
|
1216
|
+
// Numbers — orange-brown
|
|
1217
|
+
keyword: "#0969da"
|
|
1218
|
+
// true / false / null — vivid blue
|
|
1219
|
+
};
|
|
1220
|
+
var DARK = {
|
|
1221
|
+
default: "#cdd9e5",
|
|
1222
|
+
punctuation: "#768390",
|
|
1223
|
+
tag: "#57ab5a",
|
|
1224
|
+
// vivid green
|
|
1225
|
+
attr: "#dcbdfb",
|
|
1226
|
+
// vivid purple
|
|
1227
|
+
string: "#ff9492",
|
|
1228
|
+
// vivid red/pink
|
|
1229
|
+
number: "#ffa657",
|
|
1230
|
+
// orange
|
|
1231
|
+
keyword: "#6cb6ff"
|
|
1232
|
+
// vivid blue
|
|
1233
|
+
};
|
|
1234
|
+
function getColors(scheme) {
|
|
1235
|
+
return scheme === "dark" ? DARK : LIGHT;
|
|
1236
|
+
}
|
|
1237
|
+
function merge(tokens) {
|
|
1238
|
+
const out = [];
|
|
1239
|
+
for (const t of tokens) {
|
|
1240
|
+
const last = out[out.length - 1];
|
|
1241
|
+
if (last && last.color === t.color) {
|
|
1242
|
+
last.text += t.text;
|
|
1243
|
+
} else {
|
|
1244
|
+
out.push({ text: t.text, color: t.color });
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
return out;
|
|
1248
|
+
}
|
|
1249
|
+
function parseAttrToken(code, pos, tokens, C) {
|
|
1250
|
+
const ch = code[pos];
|
|
1251
|
+
if (ch === " " || ch === " ") {
|
|
1252
|
+
tokens.push({ text: ch, color: C.default });
|
|
1253
|
+
return pos + 1;
|
|
1254
|
+
}
|
|
1255
|
+
if (ch === "/" || ch === "=") {
|
|
1256
|
+
tokens.push({ text: ch, color: C.punctuation });
|
|
1257
|
+
return pos + 1;
|
|
1258
|
+
}
|
|
1259
|
+
if (ch === '"' || ch === "'") {
|
|
1260
|
+
const end = ch;
|
|
1261
|
+
let i2 = pos + 1;
|
|
1262
|
+
while (i2 < code.length && code[i2] !== end) i2++;
|
|
1263
|
+
if (i2 < code.length) i2++;
|
|
1264
|
+
tokens.push({ text: code.slice(pos, i2), color: C.string });
|
|
1265
|
+
return i2;
|
|
1266
|
+
}
|
|
1267
|
+
let i = pos;
|
|
1268
|
+
while (i < code.length && code[i] !== "=" && code[i] !== " " && code[i] !== ">" && code[i] !== "/" && code[i] !== " ")
|
|
1269
|
+
i++;
|
|
1270
|
+
if (i > pos) tokens.push({ text: code.slice(pos, i), color: C.attr });
|
|
1271
|
+
return i;
|
|
1272
|
+
}
|
|
1273
|
+
function parseTag(code, pos, tokens, C) {
|
|
1274
|
+
tokens.push({ text: "<", color: C.punctuation });
|
|
1275
|
+
let i = pos + 1;
|
|
1276
|
+
if (i < code.length && code[i] === "/") {
|
|
1277
|
+
tokens.push({ text: "/", color: C.punctuation });
|
|
1278
|
+
i++;
|
|
1279
|
+
}
|
|
1280
|
+
const nameStart = i;
|
|
1281
|
+
while (i < code.length && code[i] !== " " && code[i] !== ">" && code[i] !== "/") i++;
|
|
1282
|
+
if (i > nameStart) tokens.push({ text: code.slice(nameStart, i), color: C.tag });
|
|
1283
|
+
while (i < code.length && code[i] !== ">") {
|
|
1284
|
+
i = parseAttrToken(code, i, tokens, C);
|
|
1285
|
+
}
|
|
1286
|
+
if (i < code.length && code[i] === ">") {
|
|
1287
|
+
tokens.push({ text: ">", color: C.punctuation });
|
|
1288
|
+
i++;
|
|
1289
|
+
}
|
|
1290
|
+
return i;
|
|
1291
|
+
}
|
|
1292
|
+
function tokenizeHtml(code, scheme = "light") {
|
|
1293
|
+
const C = getColors(scheme);
|
|
1294
|
+
const tokens = [];
|
|
1295
|
+
let i = 0;
|
|
1296
|
+
while (i < code.length) {
|
|
1297
|
+
if (code[i] === "<") {
|
|
1298
|
+
i = parseTag(code, i, tokens, C);
|
|
1299
|
+
} else if (code[i] === "\n") {
|
|
1300
|
+
tokens.push({ text: "\n", color: C.default });
|
|
1301
|
+
i++;
|
|
1302
|
+
} else {
|
|
1303
|
+
const start = i;
|
|
1304
|
+
while (i < code.length && code[i] !== "<" && code[i] !== "\n") i++;
|
|
1305
|
+
if (i > start) tokens.push({ text: code.slice(start, i), color: C.default });
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
return merge(tokens);
|
|
1309
|
+
}
|
|
1310
|
+
function tokenizeJson(code, scheme = "light") {
|
|
1311
|
+
const C = getColors(scheme);
|
|
1312
|
+
const tokens = [];
|
|
1313
|
+
let i = 0;
|
|
1314
|
+
while (i < code.length) {
|
|
1315
|
+
const ch = code[i];
|
|
1316
|
+
if (ch === "\n") {
|
|
1317
|
+
tokens.push({ text: "\n", color: C.default });
|
|
1318
|
+
i++;
|
|
1319
|
+
} else if (ch === " " || ch === " ") {
|
|
1320
|
+
tokens.push({ text: ch, color: C.default });
|
|
1321
|
+
i++;
|
|
1322
|
+
} else if ("{}[]:,".includes(ch)) {
|
|
1323
|
+
tokens.push({ text: ch, color: C.punctuation });
|
|
1324
|
+
i++;
|
|
1325
|
+
} else if (ch === '"') {
|
|
1326
|
+
const start = i++;
|
|
1327
|
+
while (i < code.length) {
|
|
1328
|
+
if (code[i] === "\\") {
|
|
1329
|
+
i += 2;
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (code[i] === '"') {
|
|
1333
|
+
i++;
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1336
|
+
i++;
|
|
1337
|
+
}
|
|
1338
|
+
const str = code.slice(start, i);
|
|
1339
|
+
let j = i;
|
|
1340
|
+
while (j < code.length && (code[j] === " " || code[j] === " ")) j++;
|
|
1341
|
+
tokens.push({ text: str, color: j < code.length && code[j] === ":" ? C.attr : C.string });
|
|
1342
|
+
} else if (code.slice(i, i + 4) === "null") {
|
|
1343
|
+
tokens.push({ text: "null", color: C.keyword });
|
|
1344
|
+
i += 4;
|
|
1345
|
+
} else if (code.slice(i, i + 4) === "true") {
|
|
1346
|
+
tokens.push({ text: "true", color: C.keyword });
|
|
1347
|
+
i += 4;
|
|
1348
|
+
} else if (code.slice(i, i + 5) === "false") {
|
|
1349
|
+
tokens.push({ text: "false", color: C.keyword });
|
|
1350
|
+
i += 5;
|
|
1351
|
+
} else if (ch === "-" || ch >= "0" && ch <= "9") {
|
|
1352
|
+
const start = i;
|
|
1353
|
+
if (ch === "-") i++;
|
|
1354
|
+
while (i < code.length && /[\d.eE+-]/.test(code[i])) i++;
|
|
1355
|
+
tokens.push({ text: code.slice(start, i), color: C.number });
|
|
1356
|
+
} else {
|
|
1357
|
+
tokens.push({ text: ch, color: C.default });
|
|
1358
|
+
i++;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
return merge(tokens);
|
|
1362
|
+
}
|
|
1341
1363
|
var SchemaOrgIcons = {
|
|
1342
1364
|
// Website & WebPage
|
|
1343
1365
|
website: EarthGlobeIcon,
|
|
@@ -2981,6 +3003,55 @@ function schemaOrgOpinionNewsArticle(config = {}) {
|
|
|
2981
3003
|
);
|
|
2982
3004
|
}
|
|
2983
3005
|
|
|
3006
|
+
// src/schema/utils.ts
|
|
3007
|
+
function escapeJsonForScript(json) {
|
|
3008
|
+
return json.replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
3009
|
+
}
|
|
3010
|
+
function SchemaOrgScript({
|
|
3011
|
+
jsonLd
|
|
3012
|
+
}) {
|
|
3013
|
+
if (!jsonLd) return null;
|
|
3014
|
+
return /* @__PURE__ */ jsx(
|
|
3015
|
+
"script",
|
|
3016
|
+
{
|
|
3017
|
+
type: "application/ld+json",
|
|
3018
|
+
dangerouslySetInnerHTML: { __html: escapeJsonForScript(JSON.stringify(jsonLd)) }
|
|
3019
|
+
}
|
|
3020
|
+
);
|
|
3021
|
+
}
|
|
3022
|
+
function buildOrganizationJsonLd(data, imageUrlResolver) {
|
|
3023
|
+
var _a, _b;
|
|
3024
|
+
if (!(data == null ? void 0 : data.name) || !(data == null ? void 0 : data.url)) return null;
|
|
3025
|
+
const jsonLd = {
|
|
3026
|
+
"@context": "https://schema.org",
|
|
3027
|
+
"@type": "Organization",
|
|
3028
|
+
name: data.name,
|
|
3029
|
+
url: data.url
|
|
3030
|
+
};
|
|
3031
|
+
const logoUrl = data.logoUrl || (data.logo && imageUrlResolver ? imageUrlResolver(data.logo) : void 0);
|
|
3032
|
+
if (logoUrl) jsonLd.logo = logoUrl;
|
|
3033
|
+
if (data.description) jsonLd.description = data.description;
|
|
3034
|
+
if (data.sameAs) jsonLd.sameAs = data.sameAs;
|
|
3035
|
+
if ((_a = data.contactPoint) == null ? void 0 : _a.contactType) {
|
|
3036
|
+
const cp = {
|
|
3037
|
+
"@type": "ContactPoint",
|
|
3038
|
+
contactType: data.contactPoint.contactType
|
|
3039
|
+
};
|
|
3040
|
+
if (data.contactPoint.email) cp.email = data.contactPoint.email;
|
|
3041
|
+
if ((_b = data.contactPoint.availableLanguage) == null ? void 0 : _b.length) {
|
|
3042
|
+
cp.availableLanguage = data.contactPoint.availableLanguage;
|
|
3043
|
+
}
|
|
3044
|
+
jsonLd.contactPoint = cp;
|
|
3045
|
+
}
|
|
3046
|
+
return jsonLd;
|
|
3047
|
+
}
|
|
3048
|
+
function OrganizationSchema({
|
|
3049
|
+
data,
|
|
3050
|
+
imageUrlResolver
|
|
3051
|
+
}) {
|
|
3052
|
+
return /* @__PURE__ */ jsx(SchemaOrgScript, { jsonLd: buildOrganizationJsonLd(data, imageUrlResolver) });
|
|
3053
|
+
}
|
|
3054
|
+
|
|
2984
3055
|
// src/schema/person/schema.ts
|
|
2985
3056
|
var personFields = [
|
|
2986
3057
|
nameField({
|
|
@@ -4008,7 +4079,591 @@ function schemaOrgWebPage(config = {}) {
|
|
|
4008
4079
|
config
|
|
4009
4080
|
);
|
|
4010
4081
|
}
|
|
4082
|
+
function buildWebsiteJsonLd(data) {
|
|
4083
|
+
if (!(data == null ? void 0 : data.name) || !(data == null ? void 0 : data.url)) return null;
|
|
4084
|
+
const jsonLd = {
|
|
4085
|
+
"@context": "https://schema.org",
|
|
4086
|
+
"@type": "WebSite",
|
|
4087
|
+
name: data.name,
|
|
4088
|
+
url: data.url
|
|
4089
|
+
};
|
|
4090
|
+
if (data.description) jsonLd.description = data.description;
|
|
4091
|
+
if (data.inLanguage) jsonLd.inLanguage = data.inLanguage;
|
|
4092
|
+
const publisher = resolvePolymorphicPersonOrOrg(data.publisher);
|
|
4093
|
+
if (publisher) jsonLd.publisher = publisher;
|
|
4094
|
+
return jsonLd;
|
|
4095
|
+
}
|
|
4096
|
+
function WebsiteSchema({ data }) {
|
|
4097
|
+
return /* @__PURE__ */ jsx(SchemaOrgScript, { jsonLd: buildWebsiteJsonLd(data) });
|
|
4098
|
+
}
|
|
4099
|
+
var GENERIC_TYPES = {
|
|
4100
|
+
schemaOrgWebPage: { schemaType: "WebPage", fields: webPageFields, requiredFields: ["name"] },
|
|
4101
|
+
schemaOrgPerson: { schemaType: "Person", fields: personFields, requiredFields: ["name"] },
|
|
4102
|
+
schemaOrgBreadcrumbList: {
|
|
4103
|
+
schemaType: "BreadcrumbList",
|
|
4104
|
+
fields: breadcrumbListFields,
|
|
4105
|
+
requiredFields: []
|
|
4106
|
+
},
|
|
4107
|
+
schemaOrgImageObject: {
|
|
4108
|
+
schemaType: "ImageObject",
|
|
4109
|
+
fields: imageObjectFields,
|
|
4110
|
+
requiredFields: ["url"]
|
|
4111
|
+
},
|
|
4112
|
+
schemaOrgArticle: { schemaType: "Article", fields: articleFields, requiredFields: ["headline"] },
|
|
4113
|
+
schemaOrgBlogPosting: {
|
|
4114
|
+
schemaType: "BlogPosting",
|
|
4115
|
+
fields: blogPostingFields,
|
|
4116
|
+
requiredFields: ["headline"]
|
|
4117
|
+
},
|
|
4118
|
+
schemaOrgFAQPage: { schemaType: "FAQPage", fields: faqPageFields, requiredFields: [] },
|
|
4119
|
+
schemaOrgHowTo: { schemaType: "HowTo", fields: howToFields, requiredFields: ["name"] },
|
|
4120
|
+
schemaOrgProduct: { schemaType: "Product", fields: productFields, requiredFields: ["name"] },
|
|
4121
|
+
schemaOrgOffer: { schemaType: "Offer", fields: offerFields, requiredFields: ["price"] },
|
|
4122
|
+
schemaOrgAggregateRating: {
|
|
4123
|
+
schemaType: "AggregateRating",
|
|
4124
|
+
fields: aggregateRatingFields,
|
|
4125
|
+
requiredFields: ["ratingValue"]
|
|
4126
|
+
},
|
|
4127
|
+
schemaOrgReview: { schemaType: "Review", fields: reviewFields, requiredFields: [] },
|
|
4128
|
+
schemaOrgBrand: { schemaType: "Brand", fields: brandFields, requiredFields: ["name"] },
|
|
4129
|
+
schemaOrgLocalBusiness: {
|
|
4130
|
+
schemaType: "LocalBusiness",
|
|
4131
|
+
fields: localBusinessFields,
|
|
4132
|
+
requiredFields: ["name"]
|
|
4133
|
+
},
|
|
4134
|
+
schemaOrgPostalAddress: {
|
|
4135
|
+
schemaType: "PostalAddress",
|
|
4136
|
+
fields: postalAddressFields,
|
|
4137
|
+
requiredFields: []
|
|
4138
|
+
},
|
|
4139
|
+
schemaOrgContactPoint: {
|
|
4140
|
+
schemaType: "ContactPoint",
|
|
4141
|
+
fields: contactPointFields,
|
|
4142
|
+
requiredFields: []
|
|
4143
|
+
},
|
|
4144
|
+
schemaOrgSoftwareApplication: {
|
|
4145
|
+
schemaType: "SoftwareApplication",
|
|
4146
|
+
fields: softwareApplicationFields,
|
|
4147
|
+
requiredFields: ["name"]
|
|
4148
|
+
},
|
|
4149
|
+
schemaOrgWebApplication: {
|
|
4150
|
+
schemaType: "WebApplication",
|
|
4151
|
+
fields: webApplicationFields,
|
|
4152
|
+
requiredFields: ["name"]
|
|
4153
|
+
},
|
|
4154
|
+
schemaOrgEvent: { schemaType: "Event", fields: eventFields, requiredFields: ["name"] },
|
|
4155
|
+
schemaOrgPlace: { schemaType: "Place", fields: placeFields, requiredFields: ["name"] },
|
|
4156
|
+
schemaOrgVideoObject: {
|
|
4157
|
+
schemaType: "VideoObject",
|
|
4158
|
+
fields: videoObjectFields,
|
|
4159
|
+
requiredFields: ["name"]
|
|
4160
|
+
},
|
|
4161
|
+
schemaOrgCourse: { schemaType: "Course", fields: courseFields, requiredFields: ["name"] },
|
|
4162
|
+
schemaOrgLegalService: {
|
|
4163
|
+
schemaType: "LegalService",
|
|
4164
|
+
fields: legalServiceFields,
|
|
4165
|
+
requiredFields: ["name"]
|
|
4166
|
+
},
|
|
4167
|
+
schemaOrgCountry: { schemaType: "Country", fields: countryFields, requiredFields: ["name"] },
|
|
4168
|
+
schemaOrgBook: { schemaType: "Book", fields: bookFields, requiredFields: ["name"] },
|
|
4169
|
+
schemaOrgItemList: {
|
|
4170
|
+
schemaType: "ItemList",
|
|
4171
|
+
fields: itemListFields,
|
|
4172
|
+
requiredFields: ["name"]
|
|
4173
|
+
},
|
|
4174
|
+
schemaOrgJobPosting: {
|
|
4175
|
+
schemaType: "JobPosting",
|
|
4176
|
+
fields: jobPostingFields,
|
|
4177
|
+
requiredFields: ["title"]
|
|
4178
|
+
},
|
|
4179
|
+
schemaOrgMovie: { schemaType: "Movie", fields: movieFields, requiredFields: ["name"] },
|
|
4180
|
+
schemaOrgMusicAlbum: {
|
|
4181
|
+
schemaType: "MusicAlbum",
|
|
4182
|
+
fields: musicAlbumFields,
|
|
4183
|
+
requiredFields: ["name"]
|
|
4184
|
+
},
|
|
4185
|
+
schemaOrgMusicRecording: {
|
|
4186
|
+
schemaType: "MusicRecording",
|
|
4187
|
+
fields: musicRecordingFields,
|
|
4188
|
+
requiredFields: ["name"]
|
|
4189
|
+
},
|
|
4190
|
+
schemaOrgNewsArticle: {
|
|
4191
|
+
schemaType: "NewsArticle",
|
|
4192
|
+
fields: newsArticleFields,
|
|
4193
|
+
requiredFields: ["headline"]
|
|
4194
|
+
},
|
|
4195
|
+
schemaOrgOpinionNewsArticle: {
|
|
4196
|
+
schemaType: "OpinionNewsArticle",
|
|
4197
|
+
fields: opinionNewsArticleFields,
|
|
4198
|
+
requiredFields: ["headline"]
|
|
4199
|
+
},
|
|
4200
|
+
schemaOrgProfilePage: {
|
|
4201
|
+
schemaType: "ProfilePage",
|
|
4202
|
+
fields: profilePageFields,
|
|
4203
|
+
requiredFields: ["name"]
|
|
4204
|
+
},
|
|
4205
|
+
schemaOrgRecipe: { schemaType: "Recipe", fields: recipeFields, requiredFields: ["name"] },
|
|
4206
|
+
schemaOrgRestaurant: {
|
|
4207
|
+
schemaType: "Restaurant",
|
|
4208
|
+
fields: restaurantFields,
|
|
4209
|
+
requiredFields: ["name"]
|
|
4210
|
+
},
|
|
4211
|
+
schemaOrgService: { schemaType: "Service", fields: serviceFields, requiredFields: ["name"] },
|
|
4212
|
+
schemaOrgSocialMediaPosting: {
|
|
4213
|
+
schemaType: "SocialMediaPosting",
|
|
4214
|
+
fields: socialMediaPostingFields,
|
|
4215
|
+
requiredFields: ["headline"]
|
|
4216
|
+
}
|
|
4217
|
+
};
|
|
4218
|
+
function buildSchemaOrgJsonLd(item) {
|
|
4219
|
+
const type = item._type;
|
|
4220
|
+
if (!type) return null;
|
|
4221
|
+
if (type === "schemaOrgWebsite") {
|
|
4222
|
+
return buildWebsiteJsonLd(item);
|
|
4223
|
+
}
|
|
4224
|
+
if (type === "schemaOrgOrganization") {
|
|
4225
|
+
return buildOrganizationJsonLd(item);
|
|
4226
|
+
}
|
|
4227
|
+
const entry = GENERIC_TYPES[type];
|
|
4228
|
+
if (!entry) return null;
|
|
4229
|
+
return buildGenericJsonLd(entry.schemaType, item, entry.fields, entry.requiredFields);
|
|
4230
|
+
}
|
|
4231
|
+
function buildSchemaOrgJsonLds(data) {
|
|
4232
|
+
if (!(data == null ? void 0 : data.length)) return [];
|
|
4233
|
+
return data.map((item) => buildSchemaOrgJsonLd(item)).filter((jsonLd) => jsonLd !== null);
|
|
4234
|
+
}
|
|
4235
|
+
function SchemaOrgScripts({ data }) {
|
|
4236
|
+
if (!(data == null ? void 0 : data.length)) return null;
|
|
4237
|
+
const scripts = buildSchemaOrgJsonLds(data);
|
|
4238
|
+
if (!scripts.length) return null;
|
|
4239
|
+
return /* @__PURE__ */ jsx(Fragment, { children: scripts.map((jsonLd, idx) => (
|
|
4240
|
+
// static server-rendered scripts — order is stable, index key is safe
|
|
4241
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
4242
|
+
/* @__PURE__ */ jsx(SchemaOrgScript, { jsonLd }, `${idx}-${jsonLd["@type"]}`)
|
|
4243
|
+
)) });
|
|
4244
|
+
}
|
|
4245
|
+
function normalizeDocument(document) {
|
|
4246
|
+
var _a, _b;
|
|
4247
|
+
if (!document) return {};
|
|
4248
|
+
if ("displayed" in document || "draft" in document || "published" in document) {
|
|
4249
|
+
const viewDocument = document;
|
|
4250
|
+
const resolved = (_b = (_a = viewDocument.displayed) != null ? _a : viewDocument.draft) != null ? _b : viewDocument.published;
|
|
4251
|
+
if (resolved) return resolved;
|
|
4252
|
+
return {};
|
|
4253
|
+
}
|
|
4254
|
+
return document;
|
|
4255
|
+
}
|
|
4256
|
+
function getPathValue(source, path) {
|
|
4257
|
+
return path.split(".").reduce((current, part) => {
|
|
4258
|
+
if (!current || typeof current !== "object") return void 0;
|
|
4259
|
+
return current[part];
|
|
4260
|
+
}, source);
|
|
4261
|
+
}
|
|
4262
|
+
function resolveSlug(document, slugField) {
|
|
4263
|
+
const raw = getPathValue(document, slugField);
|
|
4264
|
+
if (typeof raw === "string") return raw;
|
|
4265
|
+
if (raw && typeof raw === "object" && "current" in raw) {
|
|
4266
|
+
const current = raw.current;
|
|
4267
|
+
return typeof current === "string" ? current : "";
|
|
4268
|
+
}
|
|
4269
|
+
return "";
|
|
4270
|
+
}
|
|
4271
|
+
function normalizePathSegment(value) {
|
|
4272
|
+
return value.replace(/^\/+|\/+$/g, "");
|
|
4273
|
+
}
|
|
4274
|
+
function resolveDocumentUrl(document, options) {
|
|
4275
|
+
if (options.urlBuilder) return options.urlBuilder(document);
|
|
4276
|
+
const baseUrl = (options.baseUrl || "https://www.example.com").replace(/\/+$/, "");
|
|
4277
|
+
const slug = normalizePathSegment(resolveSlug(document, options.slugField || "slug"));
|
|
4278
|
+
const prefix = typeof options.pathPrefix === "function" ? options.pathPrefix(document) : options.pathPrefix || "";
|
|
4279
|
+
const prefixSegment = normalizePathSegment(prefix);
|
|
4280
|
+
const path = [prefixSegment, slug].filter(Boolean).join("/");
|
|
4281
|
+
return path ? `${baseUrl}/${path}` : baseUrl;
|
|
4282
|
+
}
|
|
4283
|
+
function isSafeGroqPath(path) {
|
|
4284
|
+
return /^[A-Za-z0-9_.]+$/.test(path);
|
|
4285
|
+
}
|
|
4286
|
+
function buildDefaultSlugQuery(slugField, titleField) {
|
|
4287
|
+
if (!isSafeGroqPath(slugField) || !isSafeGroqPath(titleField)) return null;
|
|
4288
|
+
const slugExpression = slugField.endsWith(".current") ? slugField : `${slugField}.current`;
|
|
4289
|
+
return `*[_type == $type && defined(${slugExpression}) && !(_id in path("drafts.**"))] | order(${slugExpression} asc)[0...$limit]{
|
|
4290
|
+
_id,
|
|
4291
|
+
_type,
|
|
4292
|
+
"title": ${titleField},
|
|
4293
|
+
"slug": ${slugExpression}
|
|
4294
|
+
}`;
|
|
4295
|
+
}
|
|
4296
|
+
function normalizeSchemaOrgValue(value, document, schemaOrgField, schemaTypeName) {
|
|
4297
|
+
const raw = value != null ? value : getPathValue(document, schemaOrgField);
|
|
4298
|
+
if (Array.isArray(raw)) {
|
|
4299
|
+
return raw.filter((item) => !!item && typeof item === "object");
|
|
4300
|
+
}
|
|
4301
|
+
if (raw && typeof raw === "object") {
|
|
4302
|
+
const item = raw;
|
|
4303
|
+
return [__spreadValues(__spreadValues({}, schemaTypeName && !item._type ? { _type: schemaTypeName } : {}), item)];
|
|
4304
|
+
}
|
|
4305
|
+
return [];
|
|
4306
|
+
}
|
|
4307
|
+
function formatJson(value) {
|
|
4308
|
+
return JSON.stringify(value, null, 2);
|
|
4309
|
+
}
|
|
4310
|
+
function JsonLdCodeBlock({
|
|
4311
|
+
jsonLdItems,
|
|
4312
|
+
fieldPreview,
|
|
4313
|
+
scheme
|
|
4314
|
+
}) {
|
|
4315
|
+
const isDark = scheme === "dark";
|
|
4316
|
+
const codeBg = isDark ? "#161b22" : "#f6f8fa";
|
|
4317
|
+
const codeBorder = isDark ? "#30363d" : "#d0d7de";
|
|
4318
|
+
const headerBg = isDark ? "#21262d" : "#f0f2f4";
|
|
4319
|
+
const headerBorder = isDark ? "#30363d" : "#d0d7de";
|
|
4320
|
+
const headerText = isDark ? "#e6edf3" : "#24292f";
|
|
4321
|
+
const [copyLabel, setCopyLabel] = useState("Copy");
|
|
4322
|
+
const raw = formatJson(jsonLdItems.length === 1 ? jsonLdItems[0] : jsonLdItems);
|
|
4323
|
+
const tokens = useMemo(() => tokenizeJson(raw, scheme), [raw, scheme]);
|
|
4324
|
+
const handleCopy = () => {
|
|
4325
|
+
navigator.clipboard.writeText(raw).then(() => {
|
|
4326
|
+
setCopyLabel("Copied!");
|
|
4327
|
+
setTimeout(() => setCopyLabel("Copy"), 2e3);
|
|
4328
|
+
});
|
|
4329
|
+
};
|
|
4330
|
+
if (!jsonLdItems.length) {
|
|
4331
|
+
return /* @__PURE__ */ jsx(Card, { border: true, radius: 2, padding: 0, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx(Box, { padding: 3, children: /* @__PURE__ */ jsx(Text, { size: 1, muted: true, children: "Fill the required Schema.org fields to generate JSON-LD." }) }) });
|
|
4332
|
+
}
|
|
4333
|
+
return /* @__PURE__ */ jsxs("div", { style: { borderRadius: 6, border: `1px solid ${codeBorder}`, overflow: "hidden" }, children: [
|
|
4334
|
+
/* @__PURE__ */ jsxs(
|
|
4335
|
+
"div",
|
|
4336
|
+
{
|
|
4337
|
+
style: {
|
|
4338
|
+
background: headerBg,
|
|
4339
|
+
borderBottom: `1px solid ${headerBorder}`,
|
|
4340
|
+
padding: "6px 14px",
|
|
4341
|
+
display: "flex",
|
|
4342
|
+
alignItems: "center",
|
|
4343
|
+
justifyContent: "space-between"
|
|
4344
|
+
},
|
|
4345
|
+
children: [
|
|
4346
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
4347
|
+
/* @__PURE__ */ jsx(
|
|
4348
|
+
"span",
|
|
4349
|
+
{
|
|
4350
|
+
style: {
|
|
4351
|
+
width: 8,
|
|
4352
|
+
height: 8,
|
|
4353
|
+
borderRadius: "50%",
|
|
4354
|
+
background: isDark ? "#388bfd" : "#0550ae",
|
|
4355
|
+
display: "inline-block"
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
),
|
|
4359
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: 11, color: headerText, fontFamily: "monospace" }, children: "JSON-LD" })
|
|
4360
|
+
] }),
|
|
4361
|
+
/* @__PURE__ */ jsx(
|
|
4362
|
+
"button",
|
|
4363
|
+
{
|
|
4364
|
+
type: "button",
|
|
4365
|
+
onClick: handleCopy,
|
|
4366
|
+
style: {
|
|
4367
|
+
background: "none",
|
|
4368
|
+
border: `1px solid ${headerBorder}`,
|
|
4369
|
+
borderRadius: 4,
|
|
4370
|
+
padding: "2px 8px",
|
|
4371
|
+
cursor: "pointer",
|
|
4372
|
+
fontSize: 11,
|
|
4373
|
+
color: headerText
|
|
4374
|
+
},
|
|
4375
|
+
children: copyLabel
|
|
4376
|
+
}
|
|
4377
|
+
)
|
|
4378
|
+
]
|
|
4379
|
+
}
|
|
4380
|
+
),
|
|
4381
|
+
/* @__PURE__ */ jsx(
|
|
4382
|
+
Box,
|
|
4383
|
+
{
|
|
4384
|
+
as: "pre",
|
|
4385
|
+
padding: 3,
|
|
4386
|
+
style: {
|
|
4387
|
+
margin: 0,
|
|
4388
|
+
maxHeight: fieldPreview ? 360 : 520,
|
|
4389
|
+
overflow: "auto",
|
|
4390
|
+
fontSize: 12,
|
|
4391
|
+
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
|
|
4392
|
+
lineHeight: 1.6,
|
|
4393
|
+
whiteSpace: "pre-wrap",
|
|
4394
|
+
wordBreak: "break-word",
|
|
4395
|
+
backgroundColor: codeBg
|
|
4396
|
+
},
|
|
4397
|
+
children: tokens.map((token, idx) => /* @__PURE__ */ jsx("span", { style: { color: token.color }, children: token.text }, idx))
|
|
4398
|
+
}
|
|
4399
|
+
)
|
|
4400
|
+
] });
|
|
4401
|
+
}
|
|
4402
|
+
function SchemaOrgJsonLdPreview({
|
|
4403
|
+
value,
|
|
4404
|
+
document,
|
|
4405
|
+
documentId,
|
|
4406
|
+
schemaType,
|
|
4407
|
+
schemaTypeName,
|
|
4408
|
+
fieldPreview = false,
|
|
4409
|
+
baseUrl,
|
|
4410
|
+
slugField = "slug",
|
|
4411
|
+
schemaOrgField = "schemaOrg",
|
|
4412
|
+
pathPrefix,
|
|
4413
|
+
urlBuilder,
|
|
4414
|
+
apiVersion = "2024-01-01",
|
|
4415
|
+
slugQuery,
|
|
4416
|
+
showSlugList,
|
|
4417
|
+
maxSlugItems = 25,
|
|
4418
|
+
titleField = "title"
|
|
4419
|
+
}) {
|
|
4420
|
+
const { scheme } = useColorScheme();
|
|
4421
|
+
const client = useClient({ apiVersion });
|
|
4422
|
+
const initialDocument = useMemo(() => normalizeDocument(document), [document]);
|
|
4423
|
+
const [fetchedDocument, setFetchedDocument] = useState(null);
|
|
4424
|
+
const [existingSlugs, setExistingSlugs] = useState([]);
|
|
4425
|
+
const [slugListError, setSlugListError] = useState("");
|
|
4426
|
+
useEffect(() => {
|
|
4427
|
+
if (initialDocument._id || !documentId) {
|
|
4428
|
+
setFetchedDocument(null);
|
|
4429
|
+
return;
|
|
4430
|
+
}
|
|
4431
|
+
client.fetch(`*[_id == $id][0]`, { id: documentId }).then((result) => setFetchedDocument(result)).catch(() => setFetchedDocument(null));
|
|
4432
|
+
}, [client, documentId, initialDocument._id]);
|
|
4433
|
+
const currentDocument = useMemo(
|
|
4434
|
+
() => __spreadValues(__spreadValues({}, fetchedDocument != null ? fetchedDocument : initialDocument), schemaType && !(fetchedDocument != null ? fetchedDocument : initialDocument)._type ? { _type: schemaType } : {}),
|
|
4435
|
+
[fetchedDocument, initialDocument, schemaType]
|
|
4436
|
+
);
|
|
4437
|
+
const resolvedUrl = useMemo(
|
|
4438
|
+
() => resolveDocumentUrl(currentDocument, { baseUrl, slugField, pathPrefix, urlBuilder }),
|
|
4439
|
+
[currentDocument, baseUrl, slugField, pathPrefix, urlBuilder]
|
|
4440
|
+
);
|
|
4441
|
+
const items = useMemo(
|
|
4442
|
+
() => normalizeSchemaOrgValue(value, currentDocument, schemaOrgField, schemaTypeName),
|
|
4443
|
+
[value, currentDocument, schemaOrgField, schemaTypeName]
|
|
4444
|
+
);
|
|
4445
|
+
const jsonLdItems = useMemo(() => {
|
|
4446
|
+
if (Array.isArray(value != null ? value : getPathValue(currentDocument, schemaOrgField))) {
|
|
4447
|
+
return buildSchemaOrgJsonLds(items);
|
|
4448
|
+
}
|
|
4449
|
+
return items.map((item) => buildSchemaOrgJsonLd(item)).filter((jsonLd) => jsonLd !== null);
|
|
4450
|
+
}, [currentDocument, items, schemaOrgField, value]);
|
|
4451
|
+
const shouldShowSlugList = showSlugList != null ? showSlugList : !fieldPreview;
|
|
4452
|
+
const documentType = currentDocument._type;
|
|
4453
|
+
useEffect(() => {
|
|
4454
|
+
if (!shouldShowSlugList || !documentType) {
|
|
4455
|
+
setExistingSlugs([]);
|
|
4456
|
+
setSlugListError("");
|
|
4457
|
+
return;
|
|
4458
|
+
}
|
|
4459
|
+
const query = slugQuery != null ? slugQuery : buildDefaultSlugQuery(slugField, titleField);
|
|
4460
|
+
if (!query) {
|
|
4461
|
+
setExistingSlugs([]);
|
|
4462
|
+
setSlugListError("Slug list disabled because slugField/titleField is not a safe GROQ path.");
|
|
4463
|
+
return;
|
|
4464
|
+
}
|
|
4465
|
+
client.fetch(query, { type: documentType, limit: maxSlugItems }).then((result) => {
|
|
4466
|
+
setExistingSlugs(Array.isArray(result) ? result : []);
|
|
4467
|
+
setSlugListError("");
|
|
4468
|
+
}).catch(() => {
|
|
4469
|
+
setExistingSlugs([]);
|
|
4470
|
+
setSlugListError("Could not fetch existing slugs.");
|
|
4471
|
+
});
|
|
4472
|
+
}, [client, documentType, maxSlugItems, shouldShowSlugList, slugField, slugQuery, titleField]);
|
|
4473
|
+
return /* @__PURE__ */ jsx(Card, { border: true, radius: 2, padding: 3, tone: "transparent", children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
4474
|
+
/* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", gap: 3, children: [
|
|
4475
|
+
/* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: "Live JSON-LD Preview" }),
|
|
4476
|
+
/* @__PURE__ */ jsx(Text, { size: 0, muted: true, children: jsonLdItems.length ? `${jsonLdItems.length} item${jsonLdItems.length > 1 ? "s" : ""}` : "No output" })
|
|
4477
|
+
] }),
|
|
4478
|
+
/* @__PURE__ */ jsx(Card, { border: true, radius: 2, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
4479
|
+
/* @__PURE__ */ jsx(Text, { size: 0, muted: true, children: "Resolved document URL" }),
|
|
4480
|
+
/* @__PURE__ */ jsx(Text, { size: 1, style: { wordBreak: "break-word" }, children: resolvedUrl })
|
|
4481
|
+
] }) }),
|
|
4482
|
+
/* @__PURE__ */ jsx(JsonLdCodeBlock, { jsonLdItems, fieldPreview, scheme }),
|
|
4483
|
+
shouldShowSlugList && /* @__PURE__ */ jsx(Card, { border: true, radius: 2, padding: 3, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
4484
|
+
/* @__PURE__ */ jsxs(Text, { size: 1, weight: "semibold", children: [
|
|
4485
|
+
"Existing slugs",
|
|
4486
|
+
documentType ? ` for ${documentType}` : ""
|
|
4487
|
+
] }),
|
|
4488
|
+
slugListError && /* @__PURE__ */ jsx(Text, { size: 1, muted: true, children: slugListError }),
|
|
4489
|
+
!slugListError && existingSlugs.length > 0 && /* @__PURE__ */ jsx(Stack, { space: 2, children: existingSlugs.map((item) => /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", gap: 3, children: [
|
|
4490
|
+
/* @__PURE__ */ jsx(Text, { size: 1, style: { minWidth: 0 }, children: item.title || item.slug || item._id }),
|
|
4491
|
+
/* @__PURE__ */ jsx(Text, { size: 0, muted: true, style: { wordBreak: "break-word", textAlign: "right" }, children: item.slug })
|
|
4492
|
+
] }, item._id)) }),
|
|
4493
|
+
!slugListError && existingSlugs.length === 0 && /* @__PURE__ */ jsx(Text, { size: 1, muted: true, children: "No existing slugs found." })
|
|
4494
|
+
] }) })
|
|
4495
|
+
] }) });
|
|
4496
|
+
}
|
|
4497
|
+
function SchemaOrgJsonLdPreviewInput(props) {
|
|
4498
|
+
var _a, _b;
|
|
4499
|
+
const { renderDefault, schemaType } = props;
|
|
4500
|
+
const rootDocument = (_a = useFormValue([])) != null ? _a : {};
|
|
4501
|
+
const options = (_b = schemaType.options) == null ? void 0 : _b.schemaOrgJsonLdPreview;
|
|
4502
|
+
const value = props.value;
|
|
4503
|
+
return /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
4504
|
+
/* @__PURE__ */ jsx(
|
|
4505
|
+
SchemaOrgJsonLdPreview,
|
|
4506
|
+
__spreadProps(__spreadValues({}, options), {
|
|
4507
|
+
value: value != null ? value : null,
|
|
4508
|
+
document: rootDocument,
|
|
4509
|
+
schemaTypeName: schemaType.name,
|
|
4510
|
+
fieldPreview: true
|
|
4511
|
+
})
|
|
4512
|
+
),
|
|
4513
|
+
renderDefault(props)
|
|
4514
|
+
] });
|
|
4515
|
+
}
|
|
4516
|
+
|
|
4517
|
+
// src/schema/generator.ts
|
|
4518
|
+
function buildField(fieldDef, validation) {
|
|
4519
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4520
|
+
if (fieldDef.type === "select" && ((_a = fieldDef.variants) == null ? void 0 : _a.length)) {
|
|
4521
|
+
const variants = fieldDef.variants;
|
|
4522
|
+
const defaultVariant = (_b = fieldDef.defaultVariant) != null ? _b : variants[0].value;
|
|
4523
|
+
const innerFields = [
|
|
4524
|
+
{
|
|
4525
|
+
name: "variant",
|
|
4526
|
+
title: "Type",
|
|
4527
|
+
type: "string",
|
|
4528
|
+
description: "Choose how to provide this value.",
|
|
4529
|
+
initialValue: defaultVariant,
|
|
4530
|
+
options: variants.map((v) => ({ title: v.title, value: v.value })),
|
|
4531
|
+
layout: "radio"
|
|
4532
|
+
},
|
|
4533
|
+
...variants.map((v) => {
|
|
4534
|
+
if (v.fields.length === 1 && v.fields[0].name === v.value) {
|
|
4535
|
+
return v.fields[0];
|
|
4536
|
+
}
|
|
4537
|
+
return {
|
|
4538
|
+
name: v.value,
|
|
4539
|
+
title: v.title,
|
|
4540
|
+
type: "object",
|
|
4541
|
+
jsonLdType: v.jsonLdType,
|
|
4542
|
+
fields: v.fields
|
|
4543
|
+
};
|
|
4544
|
+
})
|
|
4545
|
+
];
|
|
4546
|
+
const base2 = {
|
|
4547
|
+
name: fieldDef.name,
|
|
4548
|
+
title: fieldDef.title,
|
|
4549
|
+
type: "object",
|
|
4550
|
+
fields: innerFields.map((child) => {
|
|
4551
|
+
const built = buildField(child, validation);
|
|
4552
|
+
if (child.name !== "variant") {
|
|
4553
|
+
const dv = defaultVariant;
|
|
4554
|
+
built.hidden = ({ parent }) => {
|
|
4555
|
+
var _a2;
|
|
4556
|
+
return ((_a2 = parent == null ? void 0 : parent.variant) != null ? _a2 : dv) !== child.name;
|
|
4557
|
+
};
|
|
4558
|
+
}
|
|
4559
|
+
return built;
|
|
4560
|
+
})
|
|
4561
|
+
};
|
|
4562
|
+
if (fieldDef.description) base2.description = fieldDef.description;
|
|
4563
|
+
return defineField(base2);
|
|
4564
|
+
}
|
|
4565
|
+
if (fieldDef.type === "copyrightYear") {
|
|
4566
|
+
const base2 = {
|
|
4567
|
+
name: fieldDef.name,
|
|
4568
|
+
title: fieldDef.title,
|
|
4569
|
+
type: "object",
|
|
4570
|
+
description: (_c = fieldDef.description) != null ? _c : 'Copyright year. Toggle "Use current year" to emit the current year dynamically.',
|
|
4571
|
+
fields: [
|
|
4572
|
+
defineField({
|
|
4573
|
+
name: "useDynamicYear",
|
|
4574
|
+
title: "Use current year (dynamic)",
|
|
4575
|
+
type: "boolean",
|
|
4576
|
+
initialValue: false
|
|
4577
|
+
}),
|
|
4578
|
+
defineField({
|
|
4579
|
+
name: "year",
|
|
4580
|
+
title: "Static year",
|
|
4581
|
+
type: "number",
|
|
4582
|
+
hidden: ({ parent }) => (parent == null ? void 0 : parent.useDynamicYear) === true
|
|
4583
|
+
})
|
|
4584
|
+
]
|
|
4585
|
+
};
|
|
4586
|
+
return defineField(base2);
|
|
4587
|
+
}
|
|
4588
|
+
const base = {
|
|
4589
|
+
name: fieldDef.name,
|
|
4590
|
+
title: fieldDef.title,
|
|
4591
|
+
type: fieldDef.type
|
|
4592
|
+
};
|
|
4593
|
+
if (fieldDef.description) base.description = fieldDef.description;
|
|
4594
|
+
if (fieldDef.initialValue !== void 0) base.initialValue = fieldDef.initialValue;
|
|
4595
|
+
if (fieldDef.rows) base.rows = fieldDef.rows;
|
|
4596
|
+
if (fieldDef.options) {
|
|
4597
|
+
base.options = __spreadValues({ list: fieldDef.options }, fieldDef.layout && { layout: fieldDef.layout });
|
|
4598
|
+
}
|
|
4599
|
+
if (fieldDef.type === "array" && ((_d = fieldDef.fields) == null ? void 0 : _d.length) && !fieldDef.of) {
|
|
4600
|
+
base.of = [
|
|
4601
|
+
{
|
|
4602
|
+
type: "object",
|
|
4603
|
+
fields: fieldDef.fields.map((child) => buildField(child, validation))
|
|
4604
|
+
}
|
|
4605
|
+
];
|
|
4606
|
+
} else if (fieldDef.of) {
|
|
4607
|
+
base.of = fieldDef.of;
|
|
4608
|
+
}
|
|
4609
|
+
if (fieldDef.type !== "array" && ((_e = fieldDef.fields) == null ? void 0 : _e.length)) {
|
|
4610
|
+
base.fields = fieldDef.fields.map((child) => buildField(child, validation));
|
|
4611
|
+
}
|
|
4612
|
+
if (fieldDef.type === "url" && (fieldDef.required || fieldDef.urlValidation)) {
|
|
4613
|
+
const required = fieldDef.required;
|
|
4614
|
+
const requiredMsg = required ? (_f = validation == null ? void 0 : validation[required.key]) != null ? _f : required.message : void 0;
|
|
4615
|
+
const schemes = (_h = (_g = fieldDef.urlValidation) == null ? void 0 : _g.schemes) != null ? _h : ["http", "https"];
|
|
4616
|
+
const allowRelative = (_j = (_i = fieldDef.urlValidation) == null ? void 0 : _i.allowRelative) != null ? _j : false;
|
|
4617
|
+
base.validation = (Rule) => {
|
|
4618
|
+
const checks = [];
|
|
4619
|
+
if (requiredMsg) checks.push(Rule.required().error(requiredMsg));
|
|
4620
|
+
checks.push(
|
|
4621
|
+
Rule.uri({ scheme: schemes, allowRelative }).error(
|
|
4622
|
+
`Must be a valid URL (${schemes.join(", ")}).`
|
|
4623
|
+
)
|
|
4624
|
+
);
|
|
4625
|
+
return checks;
|
|
4626
|
+
};
|
|
4627
|
+
} else if (fieldDef.required) {
|
|
4628
|
+
const msg = (_k = validation == null ? void 0 : validation[fieldDef.required.key]) != null ? _k : fieldDef.required.message;
|
|
4629
|
+
base.validation = (Rule) => Rule.required().error(msg);
|
|
4630
|
+
}
|
|
4631
|
+
return defineField(base);
|
|
4632
|
+
}
|
|
4633
|
+
function mapNameToSameValue(...items) {
|
|
4634
|
+
return items.reduce(
|
|
4635
|
+
(acc, item) => {
|
|
4636
|
+
acc[item.name] = item.name;
|
|
4637
|
+
return acc;
|
|
4638
|
+
},
|
|
4639
|
+
{}
|
|
4640
|
+
);
|
|
4641
|
+
}
|
|
4642
|
+
function generateSchemaType(def, config = {}) {
|
|
4643
|
+
const previewOptions = config.jsonLdPreview;
|
|
4644
|
+
const previewEnabled = previewOptions !== false;
|
|
4645
|
+
const previewConfig = typeof previewOptions === "object" ? previewOptions : void 0;
|
|
4646
|
+
return defineType(__spreadProps(__spreadValues(__spreadValues({
|
|
4647
|
+
name: def.name,
|
|
4648
|
+
title: def.title,
|
|
4649
|
+
type: "object"
|
|
4650
|
+
}, def.icon && { icon: def.icon }), previewEnabled && {
|
|
4651
|
+
components: { input: SchemaOrgJsonLdPreviewInput },
|
|
4652
|
+
options: { schemaOrgJsonLdPreview: previewConfig }
|
|
4653
|
+
}), {
|
|
4654
|
+
fields: def.fields.map((f) => buildField(f, config.validation)),
|
|
4655
|
+
preview: {
|
|
4656
|
+
select: mapNameToSameValue(...def.fields),
|
|
4657
|
+
prepare(selection) {
|
|
4658
|
+
return __spreadValues({
|
|
4659
|
+
title: def.title,
|
|
4660
|
+
subtitle: (def == null ? void 0 : def.customPrepareSubtitle) ? def.customPrepareSubtitle(selection) : `@type: ${def.title}`
|
|
4661
|
+
}, def.icon && { media: def.icon });
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
}));
|
|
4665
|
+
}
|
|
4011
4666
|
|
|
4012
|
-
export { IETF_LANGUAGE_OPTIONS, SchemaOrgIcons, aggregateRatingFields, articleFields, blogPostingFields, bookFields, brandFields, breadcrumbListFields, buildGenericJsonLd, contactPointFields, countryFields, courseFields, datePublishedField, descriptionField, eventFields, faqPageFields, generateSchemaType, headlineField, howToFields, imageObjectFields, inLanguageField, issnField, itemListFields, jobPostingFields, legalServiceFields, localBusinessFields, movieFields, musicAlbumFields, musicRecordingFields, nameField, newsArticleFields, offerFields, opinionNewsArticleFields, personFields, placeFields, polymorphicAdditionalType, polymorphicArchivedAt, polymorphicAuthor, polymorphicCitation, polymorphicContentRating, polymorphicContributor, polymorphicCopyrightHolder, polymorphicCreator, polymorphicFunder, polymorphicGenre, polymorphicIdentifier, polymorphicImage, polymorphicIsBasedOn, polymorphicIsPartOf, polymorphicKeywords, polymorphicLicense, polymorphicLocationCreated, polymorphicMaintainer, polymorphicMaterial, polymorphicOwner, polymorphicPublisher, postalAddressFields, potentialActionSearch, productFields, profilePageFields, recipeFields,
|
|
4013
|
-
//# sourceMappingURL=chunk-
|
|
4014
|
-
//# sourceMappingURL=chunk-
|
|
4667
|
+
export { IETF_LANGUAGE_OPTIONS, OrganizationSchema, SchemaOrgIcons, SchemaOrgJsonLdPreview, SchemaOrgJsonLdPreviewInput, SchemaOrgScript, SchemaOrgScripts, WebsiteSchema, aggregateRatingFields, articleFields, blogPostingFields, bookFields, brandFields, breadcrumbListFields, buildGenericJsonLd, buildOrganizationJsonLd, buildSchemaOrgJsonLd, buildSchemaOrgJsonLds, buildWebsiteJsonLd, contactPointFields, countryFields, courseFields, datePublishedField, descriptionField, eventFields, faqPageFields, generateSchemaType, headlineField, howToFields, imageObjectFields, inLanguageField, issnField, itemListFields, jobPostingFields, legalServiceFields, localBusinessFields, movieFields, musicAlbumFields, musicRecordingFields, nameField, newsArticleFields, offerFields, opinionNewsArticleFields, personFields, placeFields, polymorphicAdditionalType, polymorphicArchivedAt, polymorphicAuthor, polymorphicCitation, polymorphicContentRating, polymorphicContributor, polymorphicCopyrightHolder, polymorphicCreator, polymorphicFunder, polymorphicGenre, polymorphicIdentifier, polymorphicImage, polymorphicIsBasedOn, polymorphicIsPartOf, polymorphicKeywords, polymorphicLicense, polymorphicLocationCreated, polymorphicMaintainer, polymorphicMaterial, polymorphicOwner, polymorphicPublisher, postalAddressFields, potentialActionSearch, productFields, profilePageFields, recipeFields, restaurantFields, reviewFields, schemaOrgAggregateRating, schemaOrgArticle, schemaOrgBlogPosting, schemaOrgBook, schemaOrgBrand, schemaOrgBreadcrumbList, schemaOrgContactPoint, schemaOrgCountry, schemaOrgCourse, schemaOrgEvent, schemaOrgFAQPage, schemaOrgHowTo, schemaOrgImageObject, schemaOrgItemList, schemaOrgJobPosting, schemaOrgLegalService, schemaOrgLocalBusiness, schemaOrgMovie, schemaOrgMusicAlbum, schemaOrgMusicRecording, schemaOrgNewsArticle, schemaOrgOffer, schemaOrgOpinionNewsArticle, schemaOrgPerson, schemaOrgPlace, schemaOrgPostalAddress, schemaOrgProduct, schemaOrgProfilePage, schemaOrgRecipe, schemaOrgRestaurant, schemaOrgReview, schemaOrgService, schemaOrgSocialMediaPosting, schemaOrgSoftwareApplication, schemaOrgVideoObject, schemaOrgWebApplication, schemaOrgWebPage, serviceFields, socialMediaPostingFields, softwareApplicationFields, tokenizeHtml, urlField, videoObjectFields, webApplicationFields, webPageFields, withCreativeWorkCommons, withThingCommons };
|
|
4668
|
+
//# sourceMappingURL=chunk-VR44E62I.js.map
|
|
4669
|
+
//# sourceMappingURL=chunk-VR44E62I.js.map
|