sanity-plugin-seofields 1.6.5 → 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.
Files changed (82) hide show
  1. package/README.md +355 -79
  2. package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.cts +78 -0
  3. package/dist/SchemaOrgJsonLdPreview-DJLkIPq4.d.ts +78 -0
  4. package/dist/SeoHealthDashboard-AEKVVMUR-7NWV3C3Y.js +4 -0
  5. package/dist/SeoHealthDashboard-AEKVVMUR-7NWV3C3Y.js.map +1 -0
  6. package/dist/SeoHealthDashboard-AEKVVMUR-XWKJUH24.cjs +10 -0
  7. package/dist/SeoHealthDashboard-AEKVVMUR-XWKJUH24.cjs.map +1 -0
  8. package/dist/SeoHealthTool-2KKQJLJL.cjs +11 -0
  9. package/dist/{SeoHealthDashboard-BEZVLLFG.js.map → SeoHealthTool-2KKQJLJL.cjs.map} +1 -1
  10. package/dist/SeoHealthTool-3CUKGADZ.js +5 -0
  11. package/dist/{SeoHealthDashboard-D3XU3CUB.cjs.map → SeoHealthTool-3CUKGADZ.js.map} +1 -1
  12. package/dist/{SeoPreview-WYH7NYNM.cjs → SeoPreview-3EXR6FD4.cjs} +3 -3
  13. package/dist/{SeoPreview-WYH7NYNM.cjs.map → SeoPreview-3EXR6FD4.cjs.map} +1 -1
  14. package/dist/{SeoPreview-KEGGQSPJ.js → SeoPreview-4PPAF4NO.js} +3 -3
  15. package/dist/{SeoPreview-KEGGQSPJ.js.map → SeoPreview-4PPAF4NO.js.map} +1 -1
  16. package/dist/{chunk-S367Y35J.cjs → chunk-254YHUN3.cjs} +2 -15
  17. package/dist/{chunk-S367Y35J.cjs.map → chunk-254YHUN3.cjs.map} +1 -1
  18. package/dist/{chunk-HQTYQMP5.js → chunk-27XSYENH.js} +80 -29
  19. package/dist/chunk-27XSYENH.js.map +1 -0
  20. package/dist/{chunk-YHXUWGNA.cjs → chunk-B5IVI5LP.cjs} +918 -157
  21. package/dist/chunk-B5IVI5LP.cjs.map +1 -0
  22. package/dist/chunk-BNXMFD3T.cjs +431 -0
  23. package/dist/chunk-BNXMFD3T.cjs.map +1 -0
  24. package/dist/{chunk-2NMEKWO5.js → chunk-DDAAVRWG.js} +3 -15
  25. package/dist/{chunk-2NMEKWO5.js.map → chunk-DDAAVRWG.js.map} +1 -1
  26. package/dist/chunk-P6IOWIO2.cjs +480 -0
  27. package/dist/chunk-P6IOWIO2.cjs.map +1 -0
  28. package/dist/{chunk-XXA6WCWS.js → chunk-UOCZFYYP.js} +18 -203
  29. package/dist/chunk-UOCZFYYP.js.map +1 -0
  30. package/dist/{chunk-KTL6NYNG.js → chunk-VR44E62I.js} +897 -148
  31. package/dist/chunk-VR44E62I.js.map +1 -0
  32. package/dist/chunk-WKXHX3GO.js +424 -0
  33. package/dist/chunk-WKXHX3GO.js.map +1 -0
  34. package/dist/{chunk-BHIZQLY7.cjs → chunk-XZDLJ2N6.cjs} +84 -30
  35. package/dist/chunk-XZDLJ2N6.cjs.map +1 -0
  36. package/dist/cli.js +18 -18
  37. package/dist/{component-H52blyfc.d.ts → component-BzI-LHPw.d.cts} +9 -27
  38. package/dist/{component-CIE6Sy4F.d.cts → component-DEXwtemT.d.ts} +9 -27
  39. package/dist/define-cli.cjs +1 -1
  40. package/dist/define-cli.js +1 -1
  41. package/dist/index.cjs +1050 -94
  42. package/dist/index.cjs.map +1 -1
  43. package/dist/index.d.cts +75 -202
  44. package/dist/index.d.ts +75 -202
  45. package/dist/index.js +1009 -63
  46. package/dist/index.js.map +1 -1
  47. package/dist/next.cjs +138 -116
  48. package/dist/next.cjs.map +1 -1
  49. package/dist/next.d.cts +9 -3
  50. package/dist/next.d.ts +9 -3
  51. package/dist/next.js +38 -32
  52. package/dist/next.js.map +1 -1
  53. package/dist/schema/next.cjs +105 -89
  54. package/dist/schema/next.d.cts +4 -4
  55. package/dist/schema/next.d.ts +4 -4
  56. package/dist/schema/next.js +4 -4
  57. package/dist/schema.cjs +219 -157
  58. package/dist/schema.cjs.map +1 -1
  59. package/dist/schema.d.cts +30 -16
  60. package/dist/schema.d.ts +30 -16
  61. package/dist/schema.js +41 -8
  62. package/dist/schema.js.map +1 -1
  63. package/dist/{types-Dp9Pfnt9.d.ts → types-BXSCbl6p.d.cts} +47 -2
  64. package/dist/{types-CyRdIF-3.d.cts → types-B_vjMPtM.d.cts} +1 -1
  65. package/dist/{types-BxcJinOf.d.cts → types-C19cQx5D.d.ts} +47 -2
  66. package/dist/{types-CbYb4MsN.d.ts → types-CW8qFdAn.d.ts} +1 -1
  67. package/dist/{types-BtSRRG6C.d.cts → types-yVmQfby9.d.cts} +8 -16
  68. package/dist/{types-BtSRRG6C.d.ts → types-yVmQfby9.d.ts} +8 -16
  69. package/package.json +2 -1
  70. package/dist/SeoHealthDashboard-BEZVLLFG.js +0 -4
  71. package/dist/SeoHealthDashboard-D3XU3CUB.cjs +0 -10
  72. package/dist/SeoHealthTool-4VZMD4TR.cjs +0 -14
  73. package/dist/SeoHealthTool-4VZMD4TR.cjs.map +0 -1
  74. package/dist/SeoHealthTool-BSTYAKQS.js +0 -12
  75. package/dist/SeoHealthTool-BSTYAKQS.js.map +0 -1
  76. package/dist/chunk-BCTPOWXA.cjs +0 -669
  77. package/dist/chunk-BCTPOWXA.cjs.map +0 -1
  78. package/dist/chunk-BHIZQLY7.cjs.map +0 -1
  79. package/dist/chunk-HQTYQMP5.js.map +0 -1
  80. package/dist/chunk-KTL6NYNG.js.map +0 -1
  81. package/dist/chunk-XXA6WCWS.js.map +0 -1
  82. package/dist/chunk-YHXUWGNA.cjs.map +0 -1
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkS367Y35J_cjs = require('./chunk-S367Y35J.cjs');
3
+ var chunk254YHUN3_cjs = require('./chunk-254YHUN3.cjs');
4
4
  var sanity = require('sanity');
5
+ var ui = require('@sanity/ui');
6
+ var react = require('react');
5
7
  var icons = require('@sanity/icons');
8
+ var jsxRuntime = require('react/jsx-runtime');
6
9
 
7
10
  // src/schema/_shared.ts
8
11
  var imageObjectInnerFields = [
@@ -723,7 +726,7 @@ function inLanguageField(opts = {}) {
723
726
  }
724
727
  function nameField(opts = {}) {
725
728
  var _a, _b;
726
- return chunkS367Y35J_cjs.__spreadValues({
729
+ return chunk254YHUN3_cjs.__spreadValues({
727
730
  name: "name",
728
731
  title: (_a = opts.title) != null ? _a : "Name",
729
732
  type: "string",
@@ -750,7 +753,7 @@ function potentialActionSearch(opts = {}) {
750
753
  }
751
754
  function descriptionField(opts = {}) {
752
755
  var _a, _b;
753
- return chunkS367Y35J_cjs.__spreadValues({
756
+ return chunk254YHUN3_cjs.__spreadValues({
754
757
  name: "description",
755
758
  title: (_a = opts.title) != null ? _a : "Description",
756
759
  type: "text",
@@ -760,7 +763,7 @@ function descriptionField(opts = {}) {
760
763
  }
761
764
  function urlField(opts = {}) {
762
765
  var _a, _b;
763
- return chunkS367Y35J_cjs.__spreadValues({
766
+ return chunk254YHUN3_cjs.__spreadValues({
764
767
  name: "url",
765
768
  title: (_a = opts.title) != null ? _a : "URL",
766
769
  type: "url",
@@ -770,7 +773,7 @@ function urlField(opts = {}) {
770
773
  }
771
774
  function headlineField(opts = {}) {
772
775
  var _a, _b;
773
- return chunkS367Y35J_cjs.__spreadValues({
776
+ return chunk254YHUN3_cjs.__spreadValues({
774
777
  name: "headline",
775
778
  title: (_a = opts.title) != null ? _a : "Headline",
776
779
  type: "string",
@@ -779,7 +782,7 @@ function headlineField(opts = {}) {
779
782
  }
780
783
  function datePublishedField(opts = {}) {
781
784
  var _a, _b, _c, _d;
782
- return chunkS367Y35J_cjs.__spreadValues({
785
+ return chunk254YHUN3_cjs.__spreadValues({
783
786
  name: (_a = opts.name) != null ? _a : "datePublished",
784
787
  title: (_b = opts.title) != null ? _b : "Date Published",
785
788
  type: (_c = opts.dateType) != null ? _c : "date",
@@ -1064,10 +1067,10 @@ function resolvePolymorphicPersonOrOrg(input) {
1064
1067
  const obj = input;
1065
1068
  const variant = obj.variant;
1066
1069
  if (variant === "person" && obj.person && typeof obj.person === "object") {
1067
- return chunkS367Y35J_cjs.__spreadValues({ "@type": "Person" }, stripEmpty(obj.person));
1070
+ return chunk254YHUN3_cjs.__spreadValues({ "@type": "Person" }, stripEmpty(obj.person));
1068
1071
  }
1069
1072
  if (variant === "organization" && obj.organization && typeof obj.organization === "object") {
1070
- return chunkS367Y35J_cjs.__spreadValues({ "@type": "Organization" }, stripEmpty(obj.organization));
1073
+ return chunk254YHUN3_cjs.__spreadValues({ "@type": "Organization" }, stripEmpty(obj.organization));
1071
1074
  }
1072
1075
  return null;
1073
1076
  }
@@ -1083,7 +1086,7 @@ function stripEmpty(obj, exclude = []) {
1083
1086
  }
1084
1087
  function issnField(opts = {}) {
1085
1088
  var _a, _b;
1086
- return chunkS367Y35J_cjs.__spreadValues({
1089
+ return chunk254YHUN3_cjs.__spreadValues({
1087
1090
  name: "issn",
1088
1091
  title: (_a = opts.title) != null ? _a : "ISSN",
1089
1092
  type: "string",
@@ -1092,7 +1095,7 @@ function issnField(opts = {}) {
1092
1095
  }
1093
1096
  function licenseUrlField(opts = {}) {
1094
1097
  var _a, _b;
1095
- return chunkS367Y35J_cjs.__spreadValues({
1098
+ return chunk254YHUN3_cjs.__spreadValues({
1096
1099
  name: "license",
1097
1100
  title: (_a = opts.title) != null ? _a : "License URL",
1098
1101
  type: "url",
@@ -1100,148 +1103,8 @@ function licenseUrlField(opts = {}) {
1100
1103
  urlValidation: { schemes: ["http", "https"] }
1101
1104
  }, opts.required ? { required: opts.required } : {});
1102
1105
  }
1103
- function buildField(fieldDef, validation) {
1104
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1105
- if (fieldDef.type === "select" && ((_a = fieldDef.variants) == null ? void 0 : _a.length)) {
1106
- const variants = fieldDef.variants;
1107
- const defaultVariant = (_b = fieldDef.defaultVariant) != null ? _b : variants[0].value;
1108
- const innerFields = [
1109
- {
1110
- name: "variant",
1111
- title: "Type",
1112
- type: "string",
1113
- description: "Choose how to provide this value.",
1114
- initialValue: defaultVariant,
1115
- options: variants.map((v) => ({ title: v.title, value: v.value })),
1116
- layout: "radio"
1117
- },
1118
- ...variants.map((v) => {
1119
- if (v.fields.length === 1 && v.fields[0].name === v.value) {
1120
- return v.fields[0];
1121
- }
1122
- return {
1123
- name: v.value,
1124
- title: v.title,
1125
- type: "object",
1126
- jsonLdType: v.jsonLdType,
1127
- fields: v.fields
1128
- };
1129
- })
1130
- ];
1131
- const base2 = {
1132
- name: fieldDef.name,
1133
- title: fieldDef.title,
1134
- type: "object",
1135
- fields: innerFields.map((child) => {
1136
- const built = buildField(child, validation);
1137
- if (child.name !== "variant") {
1138
- const dv = defaultVariant;
1139
- built.hidden = ({ parent }) => {
1140
- var _a2;
1141
- return ((_a2 = parent == null ? void 0 : parent.variant) != null ? _a2 : dv) !== child.name;
1142
- };
1143
- }
1144
- return built;
1145
- })
1146
- };
1147
- if (fieldDef.description) base2.description = fieldDef.description;
1148
- return sanity.defineField(base2);
1149
- }
1150
- if (fieldDef.type === "copyrightYear") {
1151
- const base2 = {
1152
- name: fieldDef.name,
1153
- title: fieldDef.title,
1154
- type: "object",
1155
- description: (_c = fieldDef.description) != null ? _c : 'Copyright year. Toggle "Use current year" to emit the current year dynamically.',
1156
- fields: [
1157
- sanity.defineField({
1158
- name: "useDynamicYear",
1159
- title: "Use current year (dynamic)",
1160
- type: "boolean",
1161
- initialValue: false
1162
- }),
1163
- sanity.defineField({
1164
- name: "year",
1165
- title: "Static year",
1166
- type: "number",
1167
- hidden: ({ parent }) => (parent == null ? void 0 : parent.useDynamicYear) === true
1168
- })
1169
- ]
1170
- };
1171
- return sanity.defineField(base2);
1172
- }
1173
- const base = {
1174
- name: fieldDef.name,
1175
- title: fieldDef.title,
1176
- type: fieldDef.type
1177
- };
1178
- if (fieldDef.description) base.description = fieldDef.description;
1179
- if (fieldDef.initialValue !== void 0) base.initialValue = fieldDef.initialValue;
1180
- if (fieldDef.rows) base.rows = fieldDef.rows;
1181
- if (fieldDef.options) {
1182
- base.options = chunkS367Y35J_cjs.__spreadValues({ list: fieldDef.options }, fieldDef.layout && { layout: fieldDef.layout });
1183
- }
1184
- if (fieldDef.type === "array" && ((_d = fieldDef.fields) == null ? void 0 : _d.length) && !fieldDef.of) {
1185
- base.of = [
1186
- {
1187
- type: "object",
1188
- fields: fieldDef.fields.map((child) => buildField(child, validation))
1189
- }
1190
- ];
1191
- } else if (fieldDef.of) {
1192
- base.of = fieldDef.of;
1193
- }
1194
- if (fieldDef.type !== "array" && ((_e = fieldDef.fields) == null ? void 0 : _e.length)) {
1195
- base.fields = fieldDef.fields.map((child) => buildField(child, validation));
1196
- }
1197
- if (fieldDef.type === "url" && (fieldDef.required || fieldDef.urlValidation)) {
1198
- const required = fieldDef.required;
1199
- const requiredMsg = required ? (_f = validation == null ? void 0 : validation[required.key]) != null ? _f : required.message : void 0;
1200
- const schemes = (_h = (_g = fieldDef.urlValidation) == null ? void 0 : _g.schemes) != null ? _h : ["http", "https"];
1201
- const allowRelative = (_j = (_i = fieldDef.urlValidation) == null ? void 0 : _i.allowRelative) != null ? _j : false;
1202
- base.validation = (Rule) => {
1203
- const checks = [];
1204
- if (requiredMsg) checks.push(Rule.required().error(requiredMsg));
1205
- checks.push(
1206
- Rule.uri({ scheme: schemes, allowRelative }).error(
1207
- `Must be a valid URL (${schemes.join(", ")}).`
1208
- )
1209
- );
1210
- return checks;
1211
- };
1212
- } else if (fieldDef.required) {
1213
- const msg = (_k = validation == null ? void 0 : validation[fieldDef.required.key]) != null ? _k : fieldDef.required.message;
1214
- base.validation = (Rule) => Rule.required().error(msg);
1215
- }
1216
- return sanity.defineField(base);
1217
- }
1218
- function mapNameToSameValue(...items) {
1219
- return items.reduce(
1220
- (acc, item) => {
1221
- acc[item.name] = item.name;
1222
- return acc;
1223
- },
1224
- {}
1225
- );
1226
- }
1227
- function generateSchemaType(def, config = {}) {
1228
- return sanity.defineType(chunkS367Y35J_cjs.__spreadProps(chunkS367Y35J_cjs.__spreadValues({
1229
- name: def.name,
1230
- title: def.title,
1231
- type: "object"
1232
- }, def.icon && { icon: def.icon }), {
1233
- fields: def.fields.map((f) => buildField(f, config.validation)),
1234
- preview: {
1235
- select: mapNameToSameValue(...def.fields),
1236
- prepare(selection) {
1237
- return chunkS367Y35J_cjs.__spreadValues({
1238
- title: def.title,
1239
- subtitle: (def == null ? void 0 : def.customPrepareSubtitle) ? def.customPrepareSubtitle(selection) : `@type: ${def.title}`
1240
- }, def.icon && { media: def.icon });
1241
- }
1242
- }
1243
- }));
1244
- }
1106
+
1107
+ // src/schema/jsonLd.ts
1245
1108
  var SANITY_INTERNAL_KEYS = /* @__PURE__ */ new Set([
1246
1109
  "_key",
1247
1110
  "_type",
@@ -1267,7 +1130,7 @@ function handleSelectVariant(field, value, result, key) {
1267
1130
  return true;
1268
1131
  }
1269
1132
  const nestedSrc = obj[active.value];
1270
- if (typeof nestedSrc !== "object" || nestedSrc === null) return false;
1133
+ if (typeof nestedSrc !== "object" || nestedSrc === null) return true;
1271
1134
  const nested = buildNestedJsonLd(
1272
1135
  nestedSrc,
1273
1136
  active.fields,
@@ -1335,11 +1198,170 @@ function buildGenericJsonLd(schemaType, data, fieldDefs, requiredFields = []) {
1335
1198
  if (!data[req]) return null;
1336
1199
  }
1337
1200
  const body = buildNestedJsonLd(data, fieldDefs);
1338
- return chunkS367Y35J_cjs.__spreadValues({
1201
+ return chunk254YHUN3_cjs.__spreadValues({
1339
1202
  "@context": "https://schema.org",
1340
1203
  "@type": schemaType
1341
1204
  }, body);
1342
1205
  }
1206
+
1207
+ // src/utils/syntaxHighlight.ts
1208
+ var LIGHT = {
1209
+ default: "#24292f",
1210
+ punctuation: "#57606a",
1211
+ tag: "#1a7f37",
1212
+ // HTML tag names — vivid green
1213
+ attr: "#8250df",
1214
+ // HTML attribute names / JSON keys — vivid purple
1215
+ string: "#cf222e",
1216
+ // Attribute values / JSON string values — vivid red
1217
+ number: "#953800",
1218
+ // Numbers — orange-brown
1219
+ keyword: "#0969da"
1220
+ // true / false / null — vivid blue
1221
+ };
1222
+ var DARK = {
1223
+ default: "#cdd9e5",
1224
+ punctuation: "#768390",
1225
+ tag: "#57ab5a",
1226
+ // vivid green
1227
+ attr: "#dcbdfb",
1228
+ // vivid purple
1229
+ string: "#ff9492",
1230
+ // vivid red/pink
1231
+ number: "#ffa657",
1232
+ // orange
1233
+ keyword: "#6cb6ff"
1234
+ // vivid blue
1235
+ };
1236
+ function getColors(scheme) {
1237
+ return scheme === "dark" ? DARK : LIGHT;
1238
+ }
1239
+ function merge(tokens) {
1240
+ const out = [];
1241
+ for (const t of tokens) {
1242
+ const last = out[out.length - 1];
1243
+ if (last && last.color === t.color) {
1244
+ last.text += t.text;
1245
+ } else {
1246
+ out.push({ text: t.text, color: t.color });
1247
+ }
1248
+ }
1249
+ return out;
1250
+ }
1251
+ function parseAttrToken(code, pos, tokens, C) {
1252
+ const ch = code[pos];
1253
+ if (ch === " " || ch === " ") {
1254
+ tokens.push({ text: ch, color: C.default });
1255
+ return pos + 1;
1256
+ }
1257
+ if (ch === "/" || ch === "=") {
1258
+ tokens.push({ text: ch, color: C.punctuation });
1259
+ return pos + 1;
1260
+ }
1261
+ if (ch === '"' || ch === "'") {
1262
+ const end = ch;
1263
+ let i2 = pos + 1;
1264
+ while (i2 < code.length && code[i2] !== end) i2++;
1265
+ if (i2 < code.length) i2++;
1266
+ tokens.push({ text: code.slice(pos, i2), color: C.string });
1267
+ return i2;
1268
+ }
1269
+ let i = pos;
1270
+ while (i < code.length && code[i] !== "=" && code[i] !== " " && code[i] !== ">" && code[i] !== "/" && code[i] !== " ")
1271
+ i++;
1272
+ if (i > pos) tokens.push({ text: code.slice(pos, i), color: C.attr });
1273
+ return i;
1274
+ }
1275
+ function parseTag(code, pos, tokens, C) {
1276
+ tokens.push({ text: "<", color: C.punctuation });
1277
+ let i = pos + 1;
1278
+ if (i < code.length && code[i] === "/") {
1279
+ tokens.push({ text: "/", color: C.punctuation });
1280
+ i++;
1281
+ }
1282
+ const nameStart = i;
1283
+ while (i < code.length && code[i] !== " " && code[i] !== ">" && code[i] !== "/") i++;
1284
+ if (i > nameStart) tokens.push({ text: code.slice(nameStart, i), color: C.tag });
1285
+ while (i < code.length && code[i] !== ">") {
1286
+ i = parseAttrToken(code, i, tokens, C);
1287
+ }
1288
+ if (i < code.length && code[i] === ">") {
1289
+ tokens.push({ text: ">", color: C.punctuation });
1290
+ i++;
1291
+ }
1292
+ return i;
1293
+ }
1294
+ function tokenizeHtml(code, scheme = "light") {
1295
+ const C = getColors(scheme);
1296
+ const tokens = [];
1297
+ let i = 0;
1298
+ while (i < code.length) {
1299
+ if (code[i] === "<") {
1300
+ i = parseTag(code, i, tokens, C);
1301
+ } else if (code[i] === "\n") {
1302
+ tokens.push({ text: "\n", color: C.default });
1303
+ i++;
1304
+ } else {
1305
+ const start = i;
1306
+ while (i < code.length && code[i] !== "<" && code[i] !== "\n") i++;
1307
+ if (i > start) tokens.push({ text: code.slice(start, i), color: C.default });
1308
+ }
1309
+ }
1310
+ return merge(tokens);
1311
+ }
1312
+ function tokenizeJson(code, scheme = "light") {
1313
+ const C = getColors(scheme);
1314
+ const tokens = [];
1315
+ let i = 0;
1316
+ while (i < code.length) {
1317
+ const ch = code[i];
1318
+ if (ch === "\n") {
1319
+ tokens.push({ text: "\n", color: C.default });
1320
+ i++;
1321
+ } else if (ch === " " || ch === " ") {
1322
+ tokens.push({ text: ch, color: C.default });
1323
+ i++;
1324
+ } else if ("{}[]:,".includes(ch)) {
1325
+ tokens.push({ text: ch, color: C.punctuation });
1326
+ i++;
1327
+ } else if (ch === '"') {
1328
+ const start = i++;
1329
+ while (i < code.length) {
1330
+ if (code[i] === "\\") {
1331
+ i += 2;
1332
+ continue;
1333
+ }
1334
+ if (code[i] === '"') {
1335
+ i++;
1336
+ break;
1337
+ }
1338
+ i++;
1339
+ }
1340
+ const str = code.slice(start, i);
1341
+ let j = i;
1342
+ while (j < code.length && (code[j] === " " || code[j] === " ")) j++;
1343
+ tokens.push({ text: str, color: j < code.length && code[j] === ":" ? C.attr : C.string });
1344
+ } else if (code.slice(i, i + 4) === "null") {
1345
+ tokens.push({ text: "null", color: C.keyword });
1346
+ i += 4;
1347
+ } else if (code.slice(i, i + 4) === "true") {
1348
+ tokens.push({ text: "true", color: C.keyword });
1349
+ i += 4;
1350
+ } else if (code.slice(i, i + 5) === "false") {
1351
+ tokens.push({ text: "false", color: C.keyword });
1352
+ i += 5;
1353
+ } else if (ch === "-" || ch >= "0" && ch <= "9") {
1354
+ const start = i;
1355
+ if (ch === "-") i++;
1356
+ while (i < code.length && /[\d.eE+-]/.test(code[i])) i++;
1357
+ tokens.push({ text: code.slice(start, i), color: C.number });
1358
+ } else {
1359
+ tokens.push({ text: ch, color: C.default });
1360
+ i++;
1361
+ }
1362
+ }
1363
+ return merge(tokens);
1364
+ }
1343
1365
  var SchemaOrgIcons = {
1344
1366
  // Website & WebPage
1345
1367
  website: icons.EarthGlobeIcon,
@@ -1388,6 +1410,7 @@ var SchemaOrgIcons = {
1388
1410
  movie: icons.PlayIcon,
1389
1411
  book: icons.BookIcon,
1390
1412
  newsArticle: icons.DocumentTextIcon,
1413
+ opinionNewsArticle: icons.DocumentTextIcon,
1391
1414
  itemList: icons.ListIcon,
1392
1415
  profilePage: icons.UserIcon,
1393
1416
  musicRecording: icons.PlayIcon,
@@ -2889,6 +2912,148 @@ function schemaOrgOffer(config = {}) {
2889
2912
  );
2890
2913
  }
2891
2914
 
2915
+ // src/schema/opinionNewsArticle/schema.ts
2916
+ var opinionNewsArticleFields = [
2917
+ headlineField({
2918
+ required: { key: "headlineRequired", message: "Headline is required." },
2919
+ description: "The headline of the opinion piece (max 110 characters recommended)."
2920
+ }),
2921
+ descriptionField({
2922
+ description: "A short summary of the opinion piece (max 200 characters recommended)."
2923
+ }),
2924
+ polymorphicImage({ description: "Lead image for the article." }),
2925
+ polymorphicAuthor({
2926
+ description: "The author of the opinion piece. Use the Person variant with Job Title and Same As profile links to strengthen E-E-A-T signals."
2927
+ }),
2928
+ polymorphicPublisher({ description: "The publisher of the article." }),
2929
+ datePublishedField({
2930
+ dateType: "datetime",
2931
+ description: "When the article was first published.",
2932
+ required: { key: "datePublishedRequired", message: "Publication date is required." }
2933
+ }),
2934
+ {
2935
+ name: "dateModified",
2936
+ title: "Date Modified",
2937
+ type: "datetime",
2938
+ description: "When the article was last modified."
2939
+ },
2940
+ {
2941
+ name: "articleSection",
2942
+ title: "Article Section",
2943
+ type: "string",
2944
+ description: 'The section of the publication, e.g. "Opinion", "Editorial".'
2945
+ },
2946
+ {
2947
+ name: "articleBody",
2948
+ title: "Article Body",
2949
+ type: "text",
2950
+ rows: 6,
2951
+ description: "The actual body text of the opinion piece."
2952
+ },
2953
+ {
2954
+ name: "dateline",
2955
+ title: "Dateline",
2956
+ type: "string",
2957
+ description: 'The location from which the piece was filed, e.g. "Washington, D.C.".'
2958
+ },
2959
+ {
2960
+ name: "printColumn",
2961
+ title: "Print Column",
2962
+ type: "string",
2963
+ description: "The number of the column in which the article appears in the print edition."
2964
+ },
2965
+ {
2966
+ name: "printEdition",
2967
+ title: "Print Edition",
2968
+ type: "string",
2969
+ description: "The edition of the print product in which the article appears."
2970
+ },
2971
+ {
2972
+ name: "printPage",
2973
+ title: "Print Page",
2974
+ type: "string",
2975
+ description: 'The exact name of the page on which the article is found in print, e.g. "A5", "B18".'
2976
+ },
2977
+ {
2978
+ name: "printSection",
2979
+ title: "Print Section",
2980
+ type: "string",
2981
+ description: "The print section in which the article appeared."
2982
+ },
2983
+ {
2984
+ name: "backstory",
2985
+ title: "Backstory",
2986
+ type: "text",
2987
+ rows: 3,
2988
+ description: "Sources, context, and provenance behind this opinion piece."
2989
+ }
2990
+ ];
2991
+ function schemaOrgOpinionNewsArticle(config = {}) {
2992
+ return generateSchemaType(
2993
+ {
2994
+ name: "schemaOrgOpinionNewsArticle",
2995
+ title: "OpinionNewsArticle",
2996
+ icon: SchemaOrgIcons.opinionNewsArticle,
2997
+ fields: opinionNewsArticleFields,
2998
+ customPrepareSubtitle: (document) => {
2999
+ const headline = document.headline || "Untitled";
3000
+ const section = document.articleSection ? ` \xB7 ${document.articleSection}` : "";
3001
+ return `${headline}${section}`;
3002
+ }
3003
+ },
3004
+ config
3005
+ );
3006
+ }
3007
+
3008
+ // src/schema/utils.ts
3009
+ function escapeJsonForScript(json) {
3010
+ return json.replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
3011
+ }
3012
+ function SchemaOrgScript({
3013
+ jsonLd
3014
+ }) {
3015
+ if (!jsonLd) return null;
3016
+ return /* @__PURE__ */ jsxRuntime.jsx(
3017
+ "script",
3018
+ {
3019
+ type: "application/ld+json",
3020
+ dangerouslySetInnerHTML: { __html: escapeJsonForScript(JSON.stringify(jsonLd)) }
3021
+ }
3022
+ );
3023
+ }
3024
+ function buildOrganizationJsonLd(data, imageUrlResolver) {
3025
+ var _a, _b;
3026
+ if (!(data == null ? void 0 : data.name) || !(data == null ? void 0 : data.url)) return null;
3027
+ const jsonLd = {
3028
+ "@context": "https://schema.org",
3029
+ "@type": "Organization",
3030
+ name: data.name,
3031
+ url: data.url
3032
+ };
3033
+ const logoUrl = data.logoUrl || (data.logo && imageUrlResolver ? imageUrlResolver(data.logo) : void 0);
3034
+ if (logoUrl) jsonLd.logo = logoUrl;
3035
+ if (data.description) jsonLd.description = data.description;
3036
+ if (data.sameAs) jsonLd.sameAs = data.sameAs;
3037
+ if ((_a = data.contactPoint) == null ? void 0 : _a.contactType) {
3038
+ const cp = {
3039
+ "@type": "ContactPoint",
3040
+ contactType: data.contactPoint.contactType
3041
+ };
3042
+ if (data.contactPoint.email) cp.email = data.contactPoint.email;
3043
+ if ((_b = data.contactPoint.availableLanguage) == null ? void 0 : _b.length) {
3044
+ cp.availableLanguage = data.contactPoint.availableLanguage;
3045
+ }
3046
+ jsonLd.contactPoint = cp;
3047
+ }
3048
+ return jsonLd;
3049
+ }
3050
+ function OrganizationSchema({
3051
+ data,
3052
+ imageUrlResolver
3053
+ }) {
3054
+ return /* @__PURE__ */ jsxRuntime.jsx(SchemaOrgScript, { jsonLd: buildOrganizationJsonLd(data, imageUrlResolver) });
3055
+ }
3056
+
2892
3057
  // src/schema/person/schema.ts
2893
3058
  var personFields = [
2894
3059
  nameField({
@@ -3916,9 +4081,599 @@ function schemaOrgWebPage(config = {}) {
3916
4081
  config
3917
4082
  );
3918
4083
  }
4084
+ function buildWebsiteJsonLd(data) {
4085
+ if (!(data == null ? void 0 : data.name) || !(data == null ? void 0 : data.url)) return null;
4086
+ const jsonLd = {
4087
+ "@context": "https://schema.org",
4088
+ "@type": "WebSite",
4089
+ name: data.name,
4090
+ url: data.url
4091
+ };
4092
+ if (data.description) jsonLd.description = data.description;
4093
+ if (data.inLanguage) jsonLd.inLanguage = data.inLanguage;
4094
+ const publisher = resolvePolymorphicPersonOrOrg(data.publisher);
4095
+ if (publisher) jsonLd.publisher = publisher;
4096
+ return jsonLd;
4097
+ }
4098
+ function WebsiteSchema({ data }) {
4099
+ return /* @__PURE__ */ jsxRuntime.jsx(SchemaOrgScript, { jsonLd: buildWebsiteJsonLd(data) });
4100
+ }
4101
+ var GENERIC_TYPES = {
4102
+ schemaOrgWebPage: { schemaType: "WebPage", fields: webPageFields, requiredFields: ["name"] },
4103
+ schemaOrgPerson: { schemaType: "Person", fields: personFields, requiredFields: ["name"] },
4104
+ schemaOrgBreadcrumbList: {
4105
+ schemaType: "BreadcrumbList",
4106
+ fields: breadcrumbListFields,
4107
+ requiredFields: []
4108
+ },
4109
+ schemaOrgImageObject: {
4110
+ schemaType: "ImageObject",
4111
+ fields: imageObjectFields,
4112
+ requiredFields: ["url"]
4113
+ },
4114
+ schemaOrgArticle: { schemaType: "Article", fields: articleFields, requiredFields: ["headline"] },
4115
+ schemaOrgBlogPosting: {
4116
+ schemaType: "BlogPosting",
4117
+ fields: blogPostingFields,
4118
+ requiredFields: ["headline"]
4119
+ },
4120
+ schemaOrgFAQPage: { schemaType: "FAQPage", fields: faqPageFields, requiredFields: [] },
4121
+ schemaOrgHowTo: { schemaType: "HowTo", fields: howToFields, requiredFields: ["name"] },
4122
+ schemaOrgProduct: { schemaType: "Product", fields: productFields, requiredFields: ["name"] },
4123
+ schemaOrgOffer: { schemaType: "Offer", fields: offerFields, requiredFields: ["price"] },
4124
+ schemaOrgAggregateRating: {
4125
+ schemaType: "AggregateRating",
4126
+ fields: aggregateRatingFields,
4127
+ requiredFields: ["ratingValue"]
4128
+ },
4129
+ schemaOrgReview: { schemaType: "Review", fields: reviewFields, requiredFields: [] },
4130
+ schemaOrgBrand: { schemaType: "Brand", fields: brandFields, requiredFields: ["name"] },
4131
+ schemaOrgLocalBusiness: {
4132
+ schemaType: "LocalBusiness",
4133
+ fields: localBusinessFields,
4134
+ requiredFields: ["name"]
4135
+ },
4136
+ schemaOrgPostalAddress: {
4137
+ schemaType: "PostalAddress",
4138
+ fields: postalAddressFields,
4139
+ requiredFields: []
4140
+ },
4141
+ schemaOrgContactPoint: {
4142
+ schemaType: "ContactPoint",
4143
+ fields: contactPointFields,
4144
+ requiredFields: []
4145
+ },
4146
+ schemaOrgSoftwareApplication: {
4147
+ schemaType: "SoftwareApplication",
4148
+ fields: softwareApplicationFields,
4149
+ requiredFields: ["name"]
4150
+ },
4151
+ schemaOrgWebApplication: {
4152
+ schemaType: "WebApplication",
4153
+ fields: webApplicationFields,
4154
+ requiredFields: ["name"]
4155
+ },
4156
+ schemaOrgEvent: { schemaType: "Event", fields: eventFields, requiredFields: ["name"] },
4157
+ schemaOrgPlace: { schemaType: "Place", fields: placeFields, requiredFields: ["name"] },
4158
+ schemaOrgVideoObject: {
4159
+ schemaType: "VideoObject",
4160
+ fields: videoObjectFields,
4161
+ requiredFields: ["name"]
4162
+ },
4163
+ schemaOrgCourse: { schemaType: "Course", fields: courseFields, requiredFields: ["name"] },
4164
+ schemaOrgLegalService: {
4165
+ schemaType: "LegalService",
4166
+ fields: legalServiceFields,
4167
+ requiredFields: ["name"]
4168
+ },
4169
+ schemaOrgCountry: { schemaType: "Country", fields: countryFields, requiredFields: ["name"] },
4170
+ schemaOrgBook: { schemaType: "Book", fields: bookFields, requiredFields: ["name"] },
4171
+ schemaOrgItemList: {
4172
+ schemaType: "ItemList",
4173
+ fields: itemListFields,
4174
+ requiredFields: ["name"]
4175
+ },
4176
+ schemaOrgJobPosting: {
4177
+ schemaType: "JobPosting",
4178
+ fields: jobPostingFields,
4179
+ requiredFields: ["title"]
4180
+ },
4181
+ schemaOrgMovie: { schemaType: "Movie", fields: movieFields, requiredFields: ["name"] },
4182
+ schemaOrgMusicAlbum: {
4183
+ schemaType: "MusicAlbum",
4184
+ fields: musicAlbumFields,
4185
+ requiredFields: ["name"]
4186
+ },
4187
+ schemaOrgMusicRecording: {
4188
+ schemaType: "MusicRecording",
4189
+ fields: musicRecordingFields,
4190
+ requiredFields: ["name"]
4191
+ },
4192
+ schemaOrgNewsArticle: {
4193
+ schemaType: "NewsArticle",
4194
+ fields: newsArticleFields,
4195
+ requiredFields: ["headline"]
4196
+ },
4197
+ schemaOrgOpinionNewsArticle: {
4198
+ schemaType: "OpinionNewsArticle",
4199
+ fields: opinionNewsArticleFields,
4200
+ requiredFields: ["headline"]
4201
+ },
4202
+ schemaOrgProfilePage: {
4203
+ schemaType: "ProfilePage",
4204
+ fields: profilePageFields,
4205
+ requiredFields: ["name"]
4206
+ },
4207
+ schemaOrgRecipe: { schemaType: "Recipe", fields: recipeFields, requiredFields: ["name"] },
4208
+ schemaOrgRestaurant: {
4209
+ schemaType: "Restaurant",
4210
+ fields: restaurantFields,
4211
+ requiredFields: ["name"]
4212
+ },
4213
+ schemaOrgService: { schemaType: "Service", fields: serviceFields, requiredFields: ["name"] },
4214
+ schemaOrgSocialMediaPosting: {
4215
+ schemaType: "SocialMediaPosting",
4216
+ fields: socialMediaPostingFields,
4217
+ requiredFields: ["headline"]
4218
+ }
4219
+ };
4220
+ function buildSchemaOrgJsonLd(item) {
4221
+ const type = item._type;
4222
+ if (!type) return null;
4223
+ if (type === "schemaOrgWebsite") {
4224
+ return buildWebsiteJsonLd(item);
4225
+ }
4226
+ if (type === "schemaOrgOrganization") {
4227
+ return buildOrganizationJsonLd(item);
4228
+ }
4229
+ const entry = GENERIC_TYPES[type];
4230
+ if (!entry) return null;
4231
+ return buildGenericJsonLd(entry.schemaType, item, entry.fields, entry.requiredFields);
4232
+ }
4233
+ function buildSchemaOrgJsonLds(data) {
4234
+ if (!(data == null ? void 0 : data.length)) return [];
4235
+ return data.map((item) => buildSchemaOrgJsonLd(item)).filter((jsonLd) => jsonLd !== null);
4236
+ }
4237
+ function SchemaOrgScripts({ data }) {
4238
+ if (!(data == null ? void 0 : data.length)) return null;
4239
+ const scripts = buildSchemaOrgJsonLds(data);
4240
+ if (!scripts.length) return null;
4241
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: scripts.map((jsonLd, idx) => (
4242
+ // static server-rendered scripts — order is stable, index key is safe
4243
+ // eslint-disable-next-line react/no-array-index-key
4244
+ /* @__PURE__ */ jsxRuntime.jsx(SchemaOrgScript, { jsonLd }, `${idx}-${jsonLd["@type"]}`)
4245
+ )) });
4246
+ }
4247
+ function normalizeDocument(document) {
4248
+ var _a, _b;
4249
+ if (!document) return {};
4250
+ if ("displayed" in document || "draft" in document || "published" in document) {
4251
+ const viewDocument = document;
4252
+ const resolved = (_b = (_a = viewDocument.displayed) != null ? _a : viewDocument.draft) != null ? _b : viewDocument.published;
4253
+ if (resolved) return resolved;
4254
+ return {};
4255
+ }
4256
+ return document;
4257
+ }
4258
+ function getPathValue(source, path) {
4259
+ return path.split(".").reduce((current, part) => {
4260
+ if (!current || typeof current !== "object") return void 0;
4261
+ return current[part];
4262
+ }, source);
4263
+ }
4264
+ function resolveSlug(document, slugField) {
4265
+ const raw = getPathValue(document, slugField);
4266
+ if (typeof raw === "string") return raw;
4267
+ if (raw && typeof raw === "object" && "current" in raw) {
4268
+ const current = raw.current;
4269
+ return typeof current === "string" ? current : "";
4270
+ }
4271
+ return "";
4272
+ }
4273
+ function normalizePathSegment(value) {
4274
+ return value.replace(/^\/+|\/+$/g, "");
4275
+ }
4276
+ function resolveDocumentUrl(document, options) {
4277
+ if (options.urlBuilder) return options.urlBuilder(document);
4278
+ const baseUrl = (options.baseUrl || "https://www.example.com").replace(/\/+$/, "");
4279
+ const slug = normalizePathSegment(resolveSlug(document, options.slugField || "slug"));
4280
+ const prefix = typeof options.pathPrefix === "function" ? options.pathPrefix(document) : options.pathPrefix || "";
4281
+ const prefixSegment = normalizePathSegment(prefix);
4282
+ const path = [prefixSegment, slug].filter(Boolean).join("/");
4283
+ return path ? `${baseUrl}/${path}` : baseUrl;
4284
+ }
4285
+ function isSafeGroqPath(path) {
4286
+ return /^[A-Za-z0-9_.]+$/.test(path);
4287
+ }
4288
+ function buildDefaultSlugQuery(slugField, titleField) {
4289
+ if (!isSafeGroqPath(slugField) || !isSafeGroqPath(titleField)) return null;
4290
+ const slugExpression = slugField.endsWith(".current") ? slugField : `${slugField}.current`;
4291
+ return `*[_type == $type && defined(${slugExpression}) && !(_id in path("drafts.**"))] | order(${slugExpression} asc)[0...$limit]{
4292
+ _id,
4293
+ _type,
4294
+ "title": ${titleField},
4295
+ "slug": ${slugExpression}
4296
+ }`;
4297
+ }
4298
+ function normalizeSchemaOrgValue(value, document, schemaOrgField, schemaTypeName) {
4299
+ const raw = value != null ? value : getPathValue(document, schemaOrgField);
4300
+ if (Array.isArray(raw)) {
4301
+ return raw.filter((item) => !!item && typeof item === "object");
4302
+ }
4303
+ if (raw && typeof raw === "object") {
4304
+ const item = raw;
4305
+ return [chunk254YHUN3_cjs.__spreadValues(chunk254YHUN3_cjs.__spreadValues({}, schemaTypeName && !item._type ? { _type: schemaTypeName } : {}), item)];
4306
+ }
4307
+ return [];
4308
+ }
4309
+ function formatJson(value) {
4310
+ return JSON.stringify(value, null, 2);
4311
+ }
4312
+ function JsonLdCodeBlock({
4313
+ jsonLdItems,
4314
+ fieldPreview,
4315
+ scheme
4316
+ }) {
4317
+ const isDark = scheme === "dark";
4318
+ const codeBg = isDark ? "#161b22" : "#f6f8fa";
4319
+ const codeBorder = isDark ? "#30363d" : "#d0d7de";
4320
+ const headerBg = isDark ? "#21262d" : "#f0f2f4";
4321
+ const headerBorder = isDark ? "#30363d" : "#d0d7de";
4322
+ const headerText = isDark ? "#e6edf3" : "#24292f";
4323
+ const [copyLabel, setCopyLabel] = react.useState("Copy");
4324
+ const raw = formatJson(jsonLdItems.length === 1 ? jsonLdItems[0] : jsonLdItems);
4325
+ const tokens = react.useMemo(() => tokenizeJson(raw, scheme), [raw, scheme]);
4326
+ const handleCopy = () => {
4327
+ navigator.clipboard.writeText(raw).then(() => {
4328
+ setCopyLabel("Copied!");
4329
+ setTimeout(() => setCopyLabel("Copy"), 2e3);
4330
+ });
4331
+ };
4332
+ if (!jsonLdItems.length) {
4333
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: true, radius: 2, padding: 0, style: { overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: true, children: "Fill the required Schema.org fields to generate JSON-LD." }) }) });
4334
+ }
4335
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { borderRadius: 6, border: `1px solid ${codeBorder}`, overflow: "hidden" }, children: [
4336
+ /* @__PURE__ */ jsxRuntime.jsxs(
4337
+ "div",
4338
+ {
4339
+ style: {
4340
+ background: headerBg,
4341
+ borderBottom: `1px solid ${headerBorder}`,
4342
+ padding: "6px 14px",
4343
+ display: "flex",
4344
+ alignItems: "center",
4345
+ justifyContent: "space-between"
4346
+ },
4347
+ children: [
4348
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
4349
+ /* @__PURE__ */ jsxRuntime.jsx(
4350
+ "span",
4351
+ {
4352
+ style: {
4353
+ width: 8,
4354
+ height: 8,
4355
+ borderRadius: "50%",
4356
+ background: isDark ? "#388bfd" : "#0550ae",
4357
+ display: "inline-block"
4358
+ }
4359
+ }
4360
+ ),
4361
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 11, color: headerText, fontFamily: "monospace" }, children: "JSON-LD" })
4362
+ ] }),
4363
+ /* @__PURE__ */ jsxRuntime.jsx(
4364
+ "button",
4365
+ {
4366
+ type: "button",
4367
+ onClick: handleCopy,
4368
+ style: {
4369
+ background: "none",
4370
+ border: `1px solid ${headerBorder}`,
4371
+ borderRadius: 4,
4372
+ padding: "2px 8px",
4373
+ cursor: "pointer",
4374
+ fontSize: 11,
4375
+ color: headerText
4376
+ },
4377
+ children: copyLabel
4378
+ }
4379
+ )
4380
+ ]
4381
+ }
4382
+ ),
4383
+ /* @__PURE__ */ jsxRuntime.jsx(
4384
+ ui.Box,
4385
+ {
4386
+ as: "pre",
4387
+ padding: 3,
4388
+ style: {
4389
+ margin: 0,
4390
+ maxHeight: fieldPreview ? 360 : 520,
4391
+ overflow: "auto",
4392
+ fontSize: 12,
4393
+ fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
4394
+ lineHeight: 1.6,
4395
+ whiteSpace: "pre-wrap",
4396
+ wordBreak: "break-word",
4397
+ backgroundColor: codeBg
4398
+ },
4399
+ children: tokens.map((token, idx) => /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: token.color }, children: token.text }, idx))
4400
+ }
4401
+ )
4402
+ ] });
4403
+ }
4404
+ function SchemaOrgJsonLdPreview({
4405
+ value,
4406
+ document,
4407
+ documentId,
4408
+ schemaType,
4409
+ schemaTypeName,
4410
+ fieldPreview = false,
4411
+ baseUrl,
4412
+ slugField = "slug",
4413
+ schemaOrgField = "schemaOrg",
4414
+ pathPrefix,
4415
+ urlBuilder,
4416
+ apiVersion = "2024-01-01",
4417
+ slugQuery,
4418
+ showSlugList,
4419
+ maxSlugItems = 25,
4420
+ titleField = "title"
4421
+ }) {
4422
+ const { scheme } = sanity.useColorScheme();
4423
+ const client = sanity.useClient({ apiVersion });
4424
+ const initialDocument = react.useMemo(() => normalizeDocument(document), [document]);
4425
+ const [fetchedDocument, setFetchedDocument] = react.useState(null);
4426
+ const [existingSlugs, setExistingSlugs] = react.useState([]);
4427
+ const [slugListError, setSlugListError] = react.useState("");
4428
+ react.useEffect(() => {
4429
+ if (initialDocument._id || !documentId) {
4430
+ setFetchedDocument(null);
4431
+ return;
4432
+ }
4433
+ client.fetch(`*[_id == $id][0]`, { id: documentId }).then((result) => setFetchedDocument(result)).catch(() => setFetchedDocument(null));
4434
+ }, [client, documentId, initialDocument._id]);
4435
+ const currentDocument = react.useMemo(
4436
+ () => chunk254YHUN3_cjs.__spreadValues(chunk254YHUN3_cjs.__spreadValues({}, fetchedDocument != null ? fetchedDocument : initialDocument), schemaType && !(fetchedDocument != null ? fetchedDocument : initialDocument)._type ? { _type: schemaType } : {}),
4437
+ [fetchedDocument, initialDocument, schemaType]
4438
+ );
4439
+ const resolvedUrl = react.useMemo(
4440
+ () => resolveDocumentUrl(currentDocument, { baseUrl, slugField, pathPrefix, urlBuilder }),
4441
+ [currentDocument, baseUrl, slugField, pathPrefix, urlBuilder]
4442
+ );
4443
+ const items = react.useMemo(
4444
+ () => normalizeSchemaOrgValue(value, currentDocument, schemaOrgField, schemaTypeName),
4445
+ [value, currentDocument, schemaOrgField, schemaTypeName]
4446
+ );
4447
+ const jsonLdItems = react.useMemo(() => {
4448
+ if (Array.isArray(value != null ? value : getPathValue(currentDocument, schemaOrgField))) {
4449
+ return buildSchemaOrgJsonLds(items);
4450
+ }
4451
+ return items.map((item) => buildSchemaOrgJsonLd(item)).filter((jsonLd) => jsonLd !== null);
4452
+ }, [currentDocument, items, schemaOrgField, value]);
4453
+ const shouldShowSlugList = showSlugList != null ? showSlugList : !fieldPreview;
4454
+ const documentType = currentDocument._type;
4455
+ react.useEffect(() => {
4456
+ if (!shouldShowSlugList || !documentType) {
4457
+ setExistingSlugs([]);
4458
+ setSlugListError("");
4459
+ return;
4460
+ }
4461
+ const query = slugQuery != null ? slugQuery : buildDefaultSlugQuery(slugField, titleField);
4462
+ if (!query) {
4463
+ setExistingSlugs([]);
4464
+ setSlugListError("Slug list disabled because slugField/titleField is not a safe GROQ path.");
4465
+ return;
4466
+ }
4467
+ client.fetch(query, { type: documentType, limit: maxSlugItems }).then((result) => {
4468
+ setExistingSlugs(Array.isArray(result) ? result : []);
4469
+ setSlugListError("");
4470
+ }).catch(() => {
4471
+ setExistingSlugs([]);
4472
+ setSlugListError("Could not fetch existing slugs.");
4473
+ });
4474
+ }, [client, documentType, maxSlugItems, shouldShowSlugList, slugField, slugQuery, titleField]);
4475
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: true, radius: 2, padding: 3, tone: "transparent", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
4476
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", gap: 3, children: [
4477
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: "Live JSON-LD Preview" }),
4478
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 0, muted: true, children: jsonLdItems.length ? `${jsonLdItems.length} item${jsonLdItems.length > 1 ? "s" : ""}` : "No output" })
4479
+ ] }),
4480
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: true, radius: 2, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
4481
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 0, muted: true, children: "Resolved document URL" }),
4482
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { wordBreak: "break-word" }, children: resolvedUrl })
4483
+ ] }) }),
4484
+ /* @__PURE__ */ jsxRuntime.jsx(JsonLdCodeBlock, { jsonLdItems, fieldPreview, scheme }),
4485
+ shouldShowSlugList && /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: true, radius: 2, padding: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
4486
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "semibold", children: [
4487
+ "Existing slugs",
4488
+ documentType ? ` for ${documentType}` : ""
4489
+ ] }),
4490
+ slugListError && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: true, children: slugListError }),
4491
+ !slugListError && existingSlugs.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: existingSlugs.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", gap: 3, children: [
4492
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { minWidth: 0 }, children: item.title || item.slug || item._id }),
4493
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 0, muted: true, style: { wordBreak: "break-word", textAlign: "right" }, children: item.slug })
4494
+ ] }, item._id)) }),
4495
+ !slugListError && existingSlugs.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, muted: true, children: "No existing slugs found." })
4496
+ ] }) })
4497
+ ] }) });
4498
+ }
4499
+ function SchemaOrgJsonLdPreviewInput(props) {
4500
+ var _a, _b;
4501
+ const { renderDefault, schemaType } = props;
4502
+ const rootDocument = (_a = sanity.useFormValue([])) != null ? _a : {};
4503
+ const options = (_b = schemaType.options) == null ? void 0 : _b.schemaOrgJsonLdPreview;
4504
+ const value = props.value;
4505
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
4506
+ /* @__PURE__ */ jsxRuntime.jsx(
4507
+ SchemaOrgJsonLdPreview,
4508
+ chunk254YHUN3_cjs.__spreadProps(chunk254YHUN3_cjs.__spreadValues({}, options), {
4509
+ value: value != null ? value : null,
4510
+ document: rootDocument,
4511
+ schemaTypeName: schemaType.name,
4512
+ fieldPreview: true
4513
+ })
4514
+ ),
4515
+ renderDefault(props)
4516
+ ] });
4517
+ }
4518
+
4519
+ // src/schema/generator.ts
4520
+ function buildField(fieldDef, validation) {
4521
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4522
+ if (fieldDef.type === "select" && ((_a = fieldDef.variants) == null ? void 0 : _a.length)) {
4523
+ const variants = fieldDef.variants;
4524
+ const defaultVariant = (_b = fieldDef.defaultVariant) != null ? _b : variants[0].value;
4525
+ const innerFields = [
4526
+ {
4527
+ name: "variant",
4528
+ title: "Type",
4529
+ type: "string",
4530
+ description: "Choose how to provide this value.",
4531
+ initialValue: defaultVariant,
4532
+ options: variants.map((v) => ({ title: v.title, value: v.value })),
4533
+ layout: "radio"
4534
+ },
4535
+ ...variants.map((v) => {
4536
+ if (v.fields.length === 1 && v.fields[0].name === v.value) {
4537
+ return v.fields[0];
4538
+ }
4539
+ return {
4540
+ name: v.value,
4541
+ title: v.title,
4542
+ type: "object",
4543
+ jsonLdType: v.jsonLdType,
4544
+ fields: v.fields
4545
+ };
4546
+ })
4547
+ ];
4548
+ const base2 = {
4549
+ name: fieldDef.name,
4550
+ title: fieldDef.title,
4551
+ type: "object",
4552
+ fields: innerFields.map((child) => {
4553
+ const built = buildField(child, validation);
4554
+ if (child.name !== "variant") {
4555
+ const dv = defaultVariant;
4556
+ built.hidden = ({ parent }) => {
4557
+ var _a2;
4558
+ return ((_a2 = parent == null ? void 0 : parent.variant) != null ? _a2 : dv) !== child.name;
4559
+ };
4560
+ }
4561
+ return built;
4562
+ })
4563
+ };
4564
+ if (fieldDef.description) base2.description = fieldDef.description;
4565
+ return sanity.defineField(base2);
4566
+ }
4567
+ if (fieldDef.type === "copyrightYear") {
4568
+ const base2 = {
4569
+ name: fieldDef.name,
4570
+ title: fieldDef.title,
4571
+ type: "object",
4572
+ description: (_c = fieldDef.description) != null ? _c : 'Copyright year. Toggle "Use current year" to emit the current year dynamically.',
4573
+ fields: [
4574
+ sanity.defineField({
4575
+ name: "useDynamicYear",
4576
+ title: "Use current year (dynamic)",
4577
+ type: "boolean",
4578
+ initialValue: false
4579
+ }),
4580
+ sanity.defineField({
4581
+ name: "year",
4582
+ title: "Static year",
4583
+ type: "number",
4584
+ hidden: ({ parent }) => (parent == null ? void 0 : parent.useDynamicYear) === true
4585
+ })
4586
+ ]
4587
+ };
4588
+ return sanity.defineField(base2);
4589
+ }
4590
+ const base = {
4591
+ name: fieldDef.name,
4592
+ title: fieldDef.title,
4593
+ type: fieldDef.type
4594
+ };
4595
+ if (fieldDef.description) base.description = fieldDef.description;
4596
+ if (fieldDef.initialValue !== void 0) base.initialValue = fieldDef.initialValue;
4597
+ if (fieldDef.rows) base.rows = fieldDef.rows;
4598
+ if (fieldDef.options) {
4599
+ base.options = chunk254YHUN3_cjs.__spreadValues({ list: fieldDef.options }, fieldDef.layout && { layout: fieldDef.layout });
4600
+ }
4601
+ if (fieldDef.type === "array" && ((_d = fieldDef.fields) == null ? void 0 : _d.length) && !fieldDef.of) {
4602
+ base.of = [
4603
+ {
4604
+ type: "object",
4605
+ fields: fieldDef.fields.map((child) => buildField(child, validation))
4606
+ }
4607
+ ];
4608
+ } else if (fieldDef.of) {
4609
+ base.of = fieldDef.of;
4610
+ }
4611
+ if (fieldDef.type !== "array" && ((_e = fieldDef.fields) == null ? void 0 : _e.length)) {
4612
+ base.fields = fieldDef.fields.map((child) => buildField(child, validation));
4613
+ }
4614
+ if (fieldDef.type === "url" && (fieldDef.required || fieldDef.urlValidation)) {
4615
+ const required = fieldDef.required;
4616
+ const requiredMsg = required ? (_f = validation == null ? void 0 : validation[required.key]) != null ? _f : required.message : void 0;
4617
+ const schemes = (_h = (_g = fieldDef.urlValidation) == null ? void 0 : _g.schemes) != null ? _h : ["http", "https"];
4618
+ const allowRelative = (_j = (_i = fieldDef.urlValidation) == null ? void 0 : _i.allowRelative) != null ? _j : false;
4619
+ base.validation = (Rule) => {
4620
+ const checks = [];
4621
+ if (requiredMsg) checks.push(Rule.required().error(requiredMsg));
4622
+ checks.push(
4623
+ Rule.uri({ scheme: schemes, allowRelative }).error(
4624
+ `Must be a valid URL (${schemes.join(", ")}).`
4625
+ )
4626
+ );
4627
+ return checks;
4628
+ };
4629
+ } else if (fieldDef.required) {
4630
+ const msg = (_k = validation == null ? void 0 : validation[fieldDef.required.key]) != null ? _k : fieldDef.required.message;
4631
+ base.validation = (Rule) => Rule.required().error(msg);
4632
+ }
4633
+ return sanity.defineField(base);
4634
+ }
4635
+ function mapNameToSameValue(...items) {
4636
+ return items.reduce(
4637
+ (acc, item) => {
4638
+ acc[item.name] = item.name;
4639
+ return acc;
4640
+ },
4641
+ {}
4642
+ );
4643
+ }
4644
+ function generateSchemaType(def, config = {}) {
4645
+ const previewOptions = config.jsonLdPreview;
4646
+ const previewEnabled = previewOptions !== false;
4647
+ const previewConfig = typeof previewOptions === "object" ? previewOptions : void 0;
4648
+ return sanity.defineType(chunk254YHUN3_cjs.__spreadProps(chunk254YHUN3_cjs.__spreadValues(chunk254YHUN3_cjs.__spreadValues({
4649
+ name: def.name,
4650
+ title: def.title,
4651
+ type: "object"
4652
+ }, def.icon && { icon: def.icon }), previewEnabled && {
4653
+ components: { input: SchemaOrgJsonLdPreviewInput },
4654
+ options: { schemaOrgJsonLdPreview: previewConfig }
4655
+ }), {
4656
+ fields: def.fields.map((f) => buildField(f, config.validation)),
4657
+ preview: {
4658
+ select: mapNameToSameValue(...def.fields),
4659
+ prepare(selection) {
4660
+ return chunk254YHUN3_cjs.__spreadValues({
4661
+ title: def.title,
4662
+ subtitle: (def == null ? void 0 : def.customPrepareSubtitle) ? def.customPrepareSubtitle(selection) : `@type: ${def.title}`
4663
+ }, def.icon && { media: def.icon });
4664
+ }
4665
+ }
4666
+ }));
4667
+ }
3919
4668
 
3920
4669
  exports.IETF_LANGUAGE_OPTIONS = IETF_LANGUAGE_OPTIONS;
4670
+ exports.OrganizationSchema = OrganizationSchema;
3921
4671
  exports.SchemaOrgIcons = SchemaOrgIcons;
4672
+ exports.SchemaOrgJsonLdPreview = SchemaOrgJsonLdPreview;
4673
+ exports.SchemaOrgJsonLdPreviewInput = SchemaOrgJsonLdPreviewInput;
4674
+ exports.SchemaOrgScript = SchemaOrgScript;
4675
+ exports.SchemaOrgScripts = SchemaOrgScripts;
4676
+ exports.WebsiteSchema = WebsiteSchema;
3922
4677
  exports.aggregateRatingFields = aggregateRatingFields;
3923
4678
  exports.articleFields = articleFields;
3924
4679
  exports.blogPostingFields = blogPostingFields;
@@ -3926,6 +4681,10 @@ exports.bookFields = bookFields;
3926
4681
  exports.brandFields = brandFields;
3927
4682
  exports.breadcrumbListFields = breadcrumbListFields;
3928
4683
  exports.buildGenericJsonLd = buildGenericJsonLd;
4684
+ exports.buildOrganizationJsonLd = buildOrganizationJsonLd;
4685
+ exports.buildSchemaOrgJsonLd = buildSchemaOrgJsonLd;
4686
+ exports.buildSchemaOrgJsonLds = buildSchemaOrgJsonLds;
4687
+ exports.buildWebsiteJsonLd = buildWebsiteJsonLd;
3929
4688
  exports.contactPointFields = contactPointFields;
3930
4689
  exports.countryFields = countryFields;
3931
4690
  exports.courseFields = courseFields;
@@ -3949,6 +4708,7 @@ exports.musicRecordingFields = musicRecordingFields;
3949
4708
  exports.nameField = nameField;
3950
4709
  exports.newsArticleFields = newsArticleFields;
3951
4710
  exports.offerFields = offerFields;
4711
+ exports.opinionNewsArticleFields = opinionNewsArticleFields;
3952
4712
  exports.personFields = personFields;
3953
4713
  exports.placeFields = placeFields;
3954
4714
  exports.polymorphicAdditionalType = polymorphicAdditionalType;
@@ -3977,7 +4737,6 @@ exports.potentialActionSearch = potentialActionSearch;
3977
4737
  exports.productFields = productFields;
3978
4738
  exports.profilePageFields = profilePageFields;
3979
4739
  exports.recipeFields = recipeFields;
3980
- exports.resolvePolymorphicPersonOrOrg = resolvePolymorphicPersonOrOrg;
3981
4740
  exports.restaurantFields = restaurantFields;
3982
4741
  exports.reviewFields = reviewFields;
3983
4742
  exports.schemaOrgAggregateRating = schemaOrgAggregateRating;
@@ -4002,6 +4761,7 @@ exports.schemaOrgMusicAlbum = schemaOrgMusicAlbum;
4002
4761
  exports.schemaOrgMusicRecording = schemaOrgMusicRecording;
4003
4762
  exports.schemaOrgNewsArticle = schemaOrgNewsArticle;
4004
4763
  exports.schemaOrgOffer = schemaOrgOffer;
4764
+ exports.schemaOrgOpinionNewsArticle = schemaOrgOpinionNewsArticle;
4005
4765
  exports.schemaOrgPerson = schemaOrgPerson;
4006
4766
  exports.schemaOrgPlace = schemaOrgPlace;
4007
4767
  exports.schemaOrgPostalAddress = schemaOrgPostalAddress;
@@ -4019,11 +4779,12 @@ exports.schemaOrgWebPage = schemaOrgWebPage;
4019
4779
  exports.serviceFields = serviceFields;
4020
4780
  exports.socialMediaPostingFields = socialMediaPostingFields;
4021
4781
  exports.softwareApplicationFields = softwareApplicationFields;
4782
+ exports.tokenizeHtml = tokenizeHtml;
4022
4783
  exports.urlField = urlField;
4023
4784
  exports.videoObjectFields = videoObjectFields;
4024
4785
  exports.webApplicationFields = webApplicationFields;
4025
4786
  exports.webPageFields = webPageFields;
4026
4787
  exports.withCreativeWorkCommons = withCreativeWorkCommons;
4027
4788
  exports.withThingCommons = withThingCommons;
4028
- //# sourceMappingURL=chunk-YHXUWGNA.cjs.map
4029
- //# sourceMappingURL=chunk-YHXUWGNA.cjs.map
4789
+ //# sourceMappingURL=chunk-B5IVI5LP.cjs.map
4790
+ //# sourceMappingURL=chunk-B5IVI5LP.cjs.map