@focus-reactive/payload-plugin-seo 1.4.0 → 1.5.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 (75) hide show
  1. package/README.md +139 -124
  2. package/dist/components/SeoButton/SeoButtonInner.d.ts +2 -4
  3. package/dist/components/SeoButton/SeoButtonInner.d.ts.map +1 -1
  4. package/dist/components/SeoButton/SeoButtonInner.js +10 -7
  5. package/dist/components/SeoButton/SeoButtonInner.js.map +1 -1
  6. package/dist/components/SeoDrawer/build-analysis-input.d.ts +1 -8
  7. package/dist/components/SeoDrawer/build-analysis-input.d.ts.map +1 -1
  8. package/dist/components/SeoDrawer/build-analysis-input.js +22 -34
  9. package/dist/components/SeoDrawer/build-analysis-input.js.map +1 -1
  10. package/dist/components/SeoDrawer/buildInput.js +1 -1
  11. package/dist/components/SeoDrawer/buildInput.js.map +1 -1
  12. package/dist/components/SeoDrawer/useLiveDocument.d.ts +2 -5
  13. package/dist/components/SeoDrawer/useLiveDocument.d.ts.map +1 -1
  14. package/dist/components/SeoDrawer/useLiveDocument.js +14 -62
  15. package/dist/components/SeoDrawer/useLiveDocument.js.map +1 -1
  16. package/dist/content/index.d.ts +2 -2
  17. package/dist/content/index.d.ts.map +1 -1
  18. package/dist/content/index.js +2 -1
  19. package/dist/content/index.js.map +1 -1
  20. package/dist/content/resolve/resolve-docs.d.ts +3 -0
  21. package/dist/content/resolve/resolve-docs.d.ts.map +1 -0
  22. package/dist/content/resolve/resolve-docs.js +48 -0
  23. package/dist/content/resolve/resolve-docs.js.map +1 -0
  24. package/dist/content/schema/helpers.d.ts +1 -0
  25. package/dist/content/schema/helpers.d.ts.map +1 -1
  26. package/dist/content/schema/helpers.js +4 -0
  27. package/dist/content/schema/helpers.js.map +1 -1
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/plugin.d.ts.map +1 -1
  32. package/dist/plugin.js +18 -3
  33. package/dist/plugin.js.map +1 -1
  34. package/dist/types/config.d.ts +35 -25
  35. package/dist/types/config.d.ts.map +1 -1
  36. package/dist/utils/config/overrideAdmin.d.ts.map +1 -1
  37. package/dist/utils/config/overrideAdmin.js +2 -10
  38. package/dist/utils/config/overrideAdmin.js.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/content/extract/context.d.ts +0 -11
  41. package/dist/content/extract/context.d.ts.map +0 -1
  42. package/dist/content/extract/context.js +0 -1
  43. package/dist/content/extract/context.js.map +0 -1
  44. package/dist/content/extract/extract.d.ts +0 -18
  45. package/dist/content/extract/extract.d.ts.map +0 -1
  46. package/dist/content/extract/extract.js +0 -211
  47. package/dist/content/extract/extract.js.map +0 -1
  48. package/dist/content/extract/selection.d.ts +0 -3
  49. package/dist/content/extract/selection.d.ts.map +0 -1
  50. package/dist/content/extract/selection.js +0 -32
  51. package/dist/content/extract/selection.js.map +0 -1
  52. package/dist/content/lexical/transform.d.ts +0 -5
  53. package/dist/content/lexical/transform.d.ts.map +0 -1
  54. package/dist/content/lexical/transform.js +0 -56
  55. package/dist/content/lexical/transform.js.map +0 -1
  56. package/dist/content/resolve/collect-refs.d.ts +0 -8
  57. package/dist/content/resolve/collect-refs.d.ts.map +0 -1
  58. package/dist/content/resolve/collect-refs.js +0 -79
  59. package/dist/content/resolve/collect-refs.js.map +0 -1
  60. package/dist/content/resolve/hydrate.d.ts +0 -7
  61. package/dist/content/resolve/hydrate.d.ts.map +0 -1
  62. package/dist/content/resolve/hydrate.js +0 -123
  63. package/dist/content/resolve/hydrate.js.map +0 -1
  64. package/dist/content/resolve/resolver.d.ts +0 -7
  65. package/dist/content/resolve/resolver.d.ts.map +0 -1
  66. package/dist/content/resolve/resolver.js +0 -65
  67. package/dist/content/resolve/resolver.js.map +0 -1
  68. package/dist/content/resolve/types.d.ts +0 -12
  69. package/dist/content/resolve/types.d.ts.map +0 -1
  70. package/dist/content/resolve/types.js +0 -7
  71. package/dist/content/resolve/types.js.map +0 -1
  72. package/dist/content/walk/walkFields.d.ts +0 -17
  73. package/dist/content/walk/walkFields.d.ts.map +0 -1
  74. package/dist/content/walk/walkFields.js +0 -88
  75. package/dist/content/walk/walkFields.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SeoDrawer/build-analysis-input.ts"],"sourcesContent":["import type { ClientField } from \"payload\";\nimport type { ContentNode } from \"../../content/schema/nodes\";\nimport { serialize } from \"../../content/schema/serialize\";\nimport { extractContent } from \"../../content/extract/extract\";\nimport type { ExtractContext } from \"../../content/extract/context\";\nimport { collectRefs } from \"../../content/resolve/collect-refs\";\nimport { hydrate } from \"../../content/resolve/hydrate\";\nimport type { DocResolver } from \"../../content/resolve/resolver\";\nimport type { ResolvedDoc } from \"../../content/resolve/types\";\nimport { makeExcluded, makeIncluded } from \"../../content/extract/selection\";\nimport type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type { ContentExtractor, ContentSelection, SeoFieldPaths } from \"../../types/config\";\nimport { buildInput } from \"./buildInput\";\n\nexport interface BuildAnalysisInputArgs {\n values: Record<string, unknown>;\n locale: string | { code?: string } | null | undefined;\n payloadLocale: string | undefined;\n apiRoute?: string;\n keyphrase: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n hostFields: ClientField[];\n ctx: ExtractContext;\n resolver: DocResolver;\n resolveDepth: number;\n override?: ContentExtractor;\n}\n\nfunction normalizeSelection(content: SeoFieldPaths[\"content\"]): {\n include: string[];\n exclude: string[];\n} {\n if (content == null) return { include: [], exclude: [] };\n if (typeof content === \"string\") return { include: [content], exclude: [] };\n const sel = content as ContentSelection;\n return { include: sel.include ?? [], exclude: sel.exclude ?? [] };\n}\n\nfunction metadataPaths(fields: SeoFieldPaths): string[] {\n return [fields.seoTitle, fields.metaDescription, fields.slug ?? \"slug\"].filter((p): p is string => p !== undefined);\n}\n\nexport async function buildAnalysisInput(args: BuildAnalysisInputArgs): Promise<AnalysisInput> {\n const ir = await extractIntermediateRepresentation(args);\n const contentHtml = serialize(ir);\n\n return buildInput({\n values: args.values,\n contentHtml,\n locale: args.locale,\n keyphrase: args.keyphrase,\n fields: args.fields,\n site: args.site,\n });\n}\n\nasync function extractIntermediateRepresentation(args: BuildAnalysisInputArgs): Promise<ContentNode[]> {\n const selection = normalizeSelection(args.fields.content);\n const meta = metadataPaths(args.fields);\n\n if (args.fields.content == null) return [];\n\n const excluded = makeExcluded(meta, selection.exclude);\n const included = makeIncluded(selection.include);\n const prune = (path: string) => excluded(path) || !included(path);\n\n const refs = args.resolveDepth >= 1 ? collectRefs(args.values, args.hostFields, args.ctx, prune) : [];\n const resolved = refs.length > 0 ? await args.resolver.resolve(refs, args.payloadLocale, args.resolveDepth - 1) : new Map<string, ResolvedDoc>();\n\n const ctx: ExtractContext = { ...args.ctx, resolved };\n\n if (args.override) return await args.override(hydrate(args.values, args.hostFields, ctx, resolved), { locale: args.payloadLocale, apiRoute: args.apiRoute });\n\n return extractContent({\n values: args.values,\n fields: args.hostFields,\n ctx,\n selection,\n metadataPaths: meta,\n depth: args.resolveDepth,\n });\n}\n"],"mappings":"AAEA,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AAGxB,SAAS,cAAc,oBAAoB;AAG3C,SAAS,kBAAkB;AAiB3B,SAAS,mBAAmB,SAG1B;AACA,MAAI,WAAW;AAAM,WAAO,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC,EAAE;AACvD,MAAI,OAAO,YAAY;AAAU,WAAO,EAAE,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,EAAE;AAC1E,QAAM,MAAM;AACZ,SAAO,EAAE,SAAS,IAAI,WAAW,CAAC,GAAG,SAAS,IAAI,WAAW,CAAC,EAAE;AAClE;AAEA,SAAS,cAAc,QAAiC;AACtD,SAAO,CAAC,OAAO,UAAU,OAAO,iBAAiB,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,MAAmB,MAAM,MAAS;AAC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} from \"../../content/schema/nodes\";\nimport { serialize } from \"../../content/schema/serialize\";\nimport {\n compact,\n heading,\n html,\n image,\n link,\n paragraph,\n richText,\n video,\n} from \"../../content/schema/helpers\";\nimport { createResolveDocs } from \"../../content/resolve/resolve-docs\";\nimport type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type {\n ContentExtractor,\n ContentHelpers,\n ExtractContext,\n ExtractToolkit,\n SeoFieldPaths,\n} from \"../../types/config\";\nimport { buildInput } from \"./buildInput\";\n\nconst helpers: ContentHelpers = { heading, paragraph, link, image, video, html, richText, compact };\n\nexport interface BuildAnalysisInputArgs {\n values: Record<string, unknown>;\n locale: string | { code?: string } | null | undefined;\n payloadLocale: string | undefined;\n apiRoute?: string;\n keyphrase: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n extractor?: ContentExtractor;\n}\n\nexport async function buildAnalysisInput(args: BuildAnalysisInputArgs): Promise<AnalysisInput> {\n const ir = await extractIntermediateRepresentation(args);\n const contentHtml = serialize(ir);\n\n return buildInput({\n values: args.values,\n contentHtml,\n locale: args.locale,\n keyphrase: args.keyphrase,\n fields: args.fields,\n site: args.site,\n });\n}\n\nasync function extractIntermediateRepresentation(\n args: BuildAnalysisInputArgs\n): Promise<ContentNode[]> {\n if (!args.extractor) return [];\n\n const ctx: ExtractContext = {\n locale: args.payloadLocale,\n apiRoute: args.apiRoute,\n };\n\n const toolkit: ExtractToolkit = {\n resolveDocs: createResolveDocs(args.apiRoute, args.payloadLocale),\n helpers,\n };\n\n return await args.extractor(args.values, ctx, toolkit);\n}\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AASlC,SAAS,kBAAkB;AAE3B,MAAM,UAA0B,EAAE,SAAS,WAAW,MAAM,OAAO,OAAO,MAAM,UAAU,QAAQ;AAalG,eAAsB,mBAAmB,MAAsD;AAC7F,QAAM,KAAK,MAAM,kCAAkC,IAAI;AACvD,QAAM,cAAc,UAAU,EAAE;AAEhC,SAAO,WAAW;AAAA,IAChB,QAAQ,KAAK;AAAA,IACb;AAAA,IACA,QAAQ,KAAK;AAAA,IACb,WAAW,KAAK;AAAA,IAChB,QAAQ,KAAK;AAAA,IACb,MAAM,KAAK;AAAA,EACb,CAAC;AACH;AAEA,eAAe,kCACb,MACwB;AACxB,MAAI,CAAC,KAAK;AAAW,WAAO,CAAC;AAE7B,QAAM,MAAsB;AAAA,IAC1B,QAAQ,KAAK;AAAA,IACb,UAAU,KAAK;AAAA,EACjB;AAEA,QAAM,UAA0B;AAAA,IAC9B,aAAa,kBAAkB,KAAK,UAAU,KAAK,aAAa;AAAA,IAChE;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,UAAU,KAAK,QAAQ,KAAK,OAAO;AACvD;","names":[]}
@@ -32,7 +32,7 @@ function buildInput({
32
32
  seoTitle: Boolean(fields.seoTitle && valueAt(values, fields.seoTitle)),
33
33
  metaDescription: Boolean(fields.metaDescription),
34
34
  slug: Boolean(fields.slug ?? "slug"),
35
- content: Boolean(fields.content)
35
+ content: contentHtml.trim().length > 0
36
36
  }
37
37
  };
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SeoDrawer/buildInput.ts"],"sourcesContent":["import type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type { SeoFieldPaths } from \"../../types/config\";\n\nfunction valueAt(values: Record<string, unknown>, path?: string): string {\n if (!path) return \"\";\n\n const v = path\n .split(\".\")\n .reduce<unknown>(\n (acc, k) =>\n acc && typeof acc === \"object\" ? (acc as Record<string, unknown>)[k] : undefined,\n values\n );\n\n return typeof v === \"string\" ? v : \"\";\n}\n\nfunction normalizeLocale(locale: string | { code?: string } | null | undefined): string {\n const code =\n (typeof locale === \"object\" && locale\n ? locale.code\n : locale != null\n ? String(locale)\n : undefined) ?? \"en\";\n\n return code.includes(\"_\") ? code : `${code}_${code.toUpperCase()}`;\n}\n\nexport interface BuildInputArgs {\n values: Record<string, unknown>;\n contentHtml: string;\n locale: string | { code?: string } | null | undefined;\n keyphrase: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n}\n\nexport function buildInput({\n values,\n contentHtml,\n locale,\n keyphrase,\n fields,\n site,\n}: BuildInputArgs): AnalysisInput {\n const title = valueAt(values, fields.seoTitle) || valueAt(values, \"title\");\n\n return {\n title,\n slug: valueAt(values, fields.slug ?? \"slug\"),\n description: valueAt(values, fields.metaDescription),\n contentHtml,\n keyphrase,\n locale: normalizeLocale(locale),\n site,\n has: {\n seoTitle: Boolean(fields.seoTitle && valueAt(values, fields.seoTitle)),\n metaDescription: Boolean(fields.metaDescription),\n slug: Boolean(fields.slug ?? \"slug\"),\n content: Boolean(fields.content),\n },\n };\n}\n"],"mappings":"AAGA,SAAS,QAAQ,QAAiC,MAAuB;AACvE,MAAI,CAAC;AAAM,WAAO;AAElB,QAAM,IAAI,KACP,MAAM,GAAG,EACT;AAAA,IACC,CAAC,KAAK,MACJ,OAAO,OAAO,QAAQ,WAAY,IAAgC,CAAC,IAAI;AAAA,IACzE;AAAA,EACF;AAEF,SAAO,OAAO,MAAM,WAAW,IAAI;AACrC;AAEA,SAAS,gBAAgB,QAA+D;AACtF,QAAM,QACH,OAAO,WAAW,YAAY,SAC3B,OAAO,OACP,UAAU,OACR,OAAO,MAAM,IACb,WAAc;AAEtB,SAAO,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,IAAI,IAAI,KAAK,YAAY,CAAC;AAClE;AAWO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkC;AAChC,QAAM,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,QAAQ,QAAQ,OAAO;AAEzE,SAAO;AAAA,IACL;AAAA,IACA,MAAM,QAAQ,QAAQ,OAAO,QAAQ,MAAM;AAAA,IAC3C,aAAa,QAAQ,QAAQ,OAAO,eAAe;AAAA,IACnD;AAAA,IACA;AAAA,IACA,QAAQ,gBAAgB,MAAM;AAAA,IAC9B;AAAA,IACA,KAAK;AAAA,MACH,UAAU,QAAQ,OAAO,YAAY,QAAQ,QAAQ,OAAO,QAAQ,CAAC;AAAA,MACrE,iBAAiB,QAAQ,OAAO,eAAe;AAAA,MAC/C,MAAM,QAAQ,OAAO,QAAQ,MAAM;AAAA,MACnC,SAAS,QAAQ,OAAO,OAAO;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/SeoDrawer/buildInput.ts"],"sourcesContent":["import type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type { SeoFieldPaths } from \"../../types/config\";\n\nfunction valueAt(values: Record<string, unknown>, path?: string): string {\n if (!path) return \"\";\n\n const v = path\n .split(\".\")\n .reduce<unknown>(\n (acc, k) =>\n acc && typeof acc === \"object\" ? (acc as Record<string, unknown>)[k] : undefined,\n values\n );\n\n return typeof v === \"string\" ? v : \"\";\n}\n\nfunction normalizeLocale(locale: string | { code?: string } | null | undefined): string {\n const code =\n (typeof locale === \"object\" && locale\n ? locale.code\n : locale != null\n ? String(locale)\n : undefined) ?? \"en\";\n\n return code.includes(\"_\") ? code : `${code}_${code.toUpperCase()}`;\n}\n\nexport interface BuildInputArgs {\n values: Record<string, unknown>;\n contentHtml: string;\n locale: string | { code?: string } | null | undefined;\n keyphrase: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n}\n\nexport function buildInput({\n values,\n contentHtml,\n locale,\n keyphrase,\n fields,\n site,\n}: BuildInputArgs): AnalysisInput {\n const title = valueAt(values, fields.seoTitle) || valueAt(values, \"title\");\n\n return {\n title,\n slug: valueAt(values, fields.slug ?? \"slug\"),\n description: valueAt(values, fields.metaDescription),\n contentHtml,\n keyphrase,\n locale: normalizeLocale(locale),\n site,\n has: {\n seoTitle: Boolean(fields.seoTitle && valueAt(values, fields.seoTitle)),\n metaDescription: Boolean(fields.metaDescription),\n slug: Boolean(fields.slug ?? \"slug\"),\n content: contentHtml.trim().length > 0,\n },\n };\n}\n"],"mappings":"AAGA,SAAS,QAAQ,QAAiC,MAAuB;AACvE,MAAI,CAAC;AAAM,WAAO;AAElB,QAAM,IAAI,KACP,MAAM,GAAG,EACT;AAAA,IACC,CAAC,KAAK,MACJ,OAAO,OAAO,QAAQ,WAAY,IAAgC,CAAC,IAAI;AAAA,IACzE;AAAA,EACF;AAEF,SAAO,OAAO,MAAM,WAAW,IAAI;AACrC;AAEA,SAAS,gBAAgB,QAA+D;AACtF,QAAM,QACH,OAAO,WAAW,YAAY,SAC3B,OAAO,OACP,UAAU,OACR,OAAO,MAAM,IACb,WAAc;AAEtB,SAAO,KAAK,SAAS,GAAG,IAAI,OAAO,GAAG,IAAI,IAAI,KAAK,YAAY,CAAC;AAClE;AAWO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkC;AAChC,QAAM,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,QAAQ,QAAQ,OAAO;AAEzE,SAAO;AAAA,IACL;AAAA,IACA,MAAM,QAAQ,QAAQ,OAAO,QAAQ,MAAM;AAAA,IAC3C,aAAa,QAAQ,QAAQ,OAAO,eAAe;AAAA,IACnD;AAAA,IACA;AAAA,IACA,QAAQ,gBAAgB,MAAM;AAAA,IAC9B;AAAA,IACA,KAAK;AAAA,MACH,UAAU,QAAQ,OAAO,YAAY,QAAQ,QAAQ,OAAO,QAAQ,CAAC;AAAA,MACrE,iBAAiB,QAAQ,OAAO,eAAe;AAAA,MAC/C,MAAM,QAAQ,OAAO,QAAQ,MAAM;AAAA,MACnC,SAAS,YAAY,KAAK,EAAE,SAAS;AAAA,IACvC;AAAA,EACF;AACF;","names":[]}
@@ -9,16 +9,13 @@ export interface LiveDocArgs {
9
9
  };
10
10
  keyphrase: string;
11
11
  enabled?: boolean;
12
- extractContentPath?: string | null;
13
- resolveDepth: number;
14
- slugPaths: Record<string, string>;
12
+ extractContentPath: string;
15
13
  }
16
14
  export interface UseLiveDocumentResult {
17
15
  signature: string;
18
16
  getInput: (opts?: {
19
17
  live?: boolean;
20
18
  }) => Promise<AnalysisInput>;
21
- invalidateMedia: () => void;
22
19
  }
23
- export declare function useLiveDocument({ collectionSlug, fields, site, keyphrase, enabled, extractContentPath, resolveDepth, slugPaths, }: LiveDocArgs): UseLiveDocumentResult;
20
+ export declare function useLiveDocument({ collectionSlug: _collectionSlug, fields, site, keyphrase, enabled, extractContentPath, }: LiveDocArgs): UseLiveDocumentResult;
24
21
  //# sourceMappingURL=useLiveDocument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLiveDocument.d.ts","sourceRoot":"","sources":["../../../src/components/SeoDrawer/useLiveDocument.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOxD,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IAChE,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,eAAe,CAAC,EAC9B,cAAc,EACd,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,SAAS,GACV,EAAE,WAAW,GAAG,qBAAqB,CA8HrC"}
1
+ {"version":3,"file":"useLiveDocument.d.ts","sourceRoot":"","sources":["../../../src/components/SeoDrawer/useLiveDocument.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CACjE;AAED,wBAAgB,eAAe,CAAC,EAC9B,cAAc,EAAE,eAAe,EAC/B,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAc,EACd,kBAAkB,GACnB,EAAE,WAAW,GAAG,qBAAqB,CAwErC"}
@@ -3,59 +3,29 @@ import { useAllFormFields, useConfig, useDebounce, useLocale } from "@payloadcms
3
3
  import { reduceFieldsToValues } from "payload/shared";
4
4
  import { useCallback, useMemo, useRef } from "react";
5
5
  import { resolveContentExtractor } from "../../content/registry";
6
- import { createDocResolver } from "../../content/resolve/resolver";
7
6
  import { buildAnalysisInput } from "./build-analysis-input";
8
- const warnedPaths = /* @__PURE__ */ new Set();
7
+ const erroredPaths = /* @__PURE__ */ new Set();
9
8
  const DEBOUNCE_MS = 1e3;
10
9
  function useLiveDocument({
11
- collectionSlug,
10
+ collectionSlug: _collectionSlug,
12
11
  fields,
13
12
  site,
14
13
  keyphrase,
15
14
  enabled = true,
16
- extractContentPath,
17
- resolveDepth,
18
- slugPaths
15
+ extractContentPath
19
16
  }) {
20
17
  const [formFields] = useAllFormFields();
21
18
  const locale = useLocale();
22
- const { config, getEntityConfig } = useConfig();
19
+ const { config } = useConfig();
23
20
  const debouncedFields = useDebounce(formFields, DEBOUNCE_MS);
24
21
  const debouncedKeyphrase = useDebounce(keyphrase, DEBOUNCE_MS);
25
22
  const apiRoute = config.routes.api;
26
- const resolver = useMemo(() => createDocResolver(apiRoute), [apiRoute]);
27
- const getFields = useCallback(
28
- (slug) => {
29
- const entity = getEntityConfig({ collectionSlug: slug });
30
- return entity?.fields ?? [];
31
- },
32
- [getEntityConfig]
33
- );
34
- const hostFields = useMemo(
35
- () => getFields(collectionSlug),
36
- [getFields, collectionSlug]
37
- );
38
- const ctx = useMemo(
39
- () => ({
40
- getFields,
41
- isUploadCollection: (slug) => Boolean(config.collections?.find((c) => c.slug === slug)?.upload),
42
- slugPath: (slug) => slugPaths[slug] ?? "slug",
43
- blocksBySlug: { ...config.blocksMap },
44
- resolved: /* @__PURE__ */ new Map(),
45
- baseUrl: site.baseUrl
46
- }),
47
- [getFields, config, slugPaths, site.baseUrl]
48
- );
49
23
  const values = useMemo(
50
24
  () => enabled ? reduceFieldsToValues(debouncedFields, true) : {},
51
25
  [enabled, debouncedFields]
52
26
  );
53
27
  const signature = useMemo(
54
- () => JSON.stringify({
55
- values,
56
- keyphrase: debouncedKeyphrase,
57
- locale: locale?.code ?? null
58
- }),
28
+ () => JSON.stringify({ values, keyphrase: debouncedKeyphrase, locale: locale?.code ?? null }),
59
29
  [values, debouncedKeyphrase, locale]
60
30
  );
61
31
  const liveRef = useRef({
@@ -67,10 +37,6 @@ function useLiveDocument({
67
37
  fields,
68
38
  site,
69
39
  extractContentPath,
70
- hostFields,
71
- ctx,
72
- resolver,
73
- resolveDepth,
74
40
  apiRoute
75
41
  });
76
42
  liveRef.current = {
@@ -82,28 +48,19 @@ function useLiveDocument({
82
48
  fields,
83
49
  site,
84
50
  extractContentPath,
85
- hostFields,
86
- ctx,
87
- resolver,
88
- resolveDepth,
89
51
  apiRoute
90
52
  };
91
53
  const getInput = useCallback(
92
54
  async ({ live = false } = {}) => {
93
55
  const s = liveRef.current;
94
56
  const inputValues = live ? reduceFieldsToValues(s.formFields, true) : s.values;
95
- const override = (() => {
96
- if (!s.extractContentPath)
97
- return void 0;
98
- const fn = resolveContentExtractor(s.extractContentPath);
99
- if (!fn && !warnedPaths.has(s.extractContentPath)) {
100
- warnedPaths.add(s.extractContentPath);
101
- console.warn(
102
- `[payload-plugin-seo] extractContentPath "${s.extractContentPath}" is not registered; falling back to the built-in extractor. Call registerContentExtractors from "@focus-reactive/payload-plugin-seo/content" in an admin-mounted client module.`
103
- );
104
- }
105
- return fn;
106
- })();
57
+ const extractor = resolveContentExtractor(s.extractContentPath);
58
+ if (!extractor && !erroredPaths.has(s.extractContentPath)) {
59
+ erroredPaths.add(s.extractContentPath);
60
+ console.error(
61
+ `[payload-plugin-seo] extractContentPath "${s.extractContentPath}" is not registered; content analysis will be empty. Call registerContentExtractors from "@focus-reactive/payload-plugin-seo/content" in an admin-mounted client module.`
62
+ );
63
+ }
107
64
  return buildAnalysisInput({
108
65
  values: inputValues,
109
66
  locale: s.locale,
@@ -112,17 +69,12 @@ function useLiveDocument({
112
69
  keyphrase: live ? s.keyphrase : s.debouncedKeyphrase,
113
70
  fields: s.fields,
114
71
  site: s.site,
115
- hostFields: s.hostFields,
116
- ctx: s.ctx,
117
- resolver: s.resolver,
118
- resolveDepth: s.resolveDepth,
119
- override
72
+ extractor
120
73
  });
121
74
  },
122
75
  []
123
76
  );
124
- const invalidateMedia = useCallback(() => liveRef.current.resolver.invalidate(), []);
125
- return { signature, getInput, invalidateMedia };
77
+ return { signature, getInput };
126
78
  }
127
79
  export {
128
80
  useLiveDocument
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SeoDrawer/useLiveDocument.ts"],"sourcesContent":["\"use client\";\n\nimport { useAllFormFields, useConfig, useDebounce, useLocale } from \"@payloadcms/ui\";\nimport type { ClientField } from \"payload\";\nimport { reduceFieldsToValues } from \"payload/shared\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { resolveContentExtractor } from \"../../content/registry\";\nimport { createDocResolver } from \"../../content/resolve/resolver\";\nimport type { ExtractContext } from \"../../content/extract/context\";\nimport type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type { SeoFieldPaths } from \"../../types/config\";\nimport { buildAnalysisInput } from \"./build-analysis-input\";\n\nconst warnedPaths = new Set<string>();\n\nconst DEBOUNCE_MS = 1000;\n\nexport interface LiveDocArgs {\n collectionSlug: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n keyphrase: string;\n enabled?: boolean;\n extractContentPath?: string | null;\n resolveDepth: number;\n slugPaths: Record<string, string>;\n}\n\nexport interface UseLiveDocumentResult {\n signature: string;\n getInput: (opts?: { live?: boolean }) => Promise<AnalysisInput>;\n invalidateMedia: () => void;\n}\n\nexport function useLiveDocument({\n collectionSlug,\n fields,\n site,\n keyphrase,\n enabled = true,\n extractContentPath,\n resolveDepth,\n slugPaths,\n}: LiveDocArgs): UseLiveDocumentResult {\n const [formFields] = useAllFormFields();\n const locale = useLocale();\n const { config, getEntityConfig } = useConfig();\n\n const debouncedFields = useDebounce(formFields, DEBOUNCE_MS);\n const debouncedKeyphrase = useDebounce(keyphrase, DEBOUNCE_MS);\n\n const apiRoute = config.routes.api;\n const resolver = useMemo(() => createDocResolver(apiRoute), [apiRoute]);\n\n const getFields = useCallback(\n (slug: string): ClientField[] => {\n const entity = getEntityConfig({ collectionSlug: slug as never }) as\n | { fields?: ClientField[] }\n | undefined;\n return entity?.fields ?? [];\n },\n [getEntityConfig]\n );\n\n const hostFields = useMemo<ClientField[]>(\n () => getFields(collectionSlug),\n [getFields, collectionSlug]\n );\n\n const ctx = useMemo<ExtractContext>(\n () => ({\n getFields,\n isUploadCollection: (slug) =>\n Boolean(config.collections?.find((c) => c.slug === slug)?.upload),\n slugPath: (slug) => slugPaths[slug] ?? \"slug\",\n blocksBySlug: { ...config.blocksMap },\n resolved: new Map(),\n baseUrl: site.baseUrl,\n }),\n [getFields, config, slugPaths, site.baseUrl]\n );\n\n const values = useMemo<Record<string, unknown>>(\n () => (enabled ? (reduceFieldsToValues(debouncedFields, true) as Record<string, unknown>) : {}),\n [enabled, debouncedFields]\n );\n\n const signature = useMemo(\n () =>\n JSON.stringify({\n values,\n keyphrase: debouncedKeyphrase,\n locale: locale?.code ?? null,\n }),\n [values, debouncedKeyphrase, locale]\n );\n\n const liveRef = useRef({\n formFields,\n values,\n keyphrase,\n debouncedKeyphrase,\n locale,\n fields,\n site,\n extractContentPath,\n hostFields,\n ctx,\n resolver,\n resolveDepth,\n apiRoute,\n });\n liveRef.current = {\n formFields,\n values,\n keyphrase,\n debouncedKeyphrase,\n locale,\n fields,\n site,\n extractContentPath,\n hostFields,\n ctx,\n resolver,\n resolveDepth,\n apiRoute,\n };\n\n const getInput = useCallback(\n async ({ live = false }: { live?: boolean } = {}): Promise<AnalysisInput> => {\n const s = liveRef.current;\n const inputValues = live\n ? (reduceFieldsToValues(s.formFields, true) as Record<string, unknown>)\n : s.values;\n\n const override = (() => {\n if (!s.extractContentPath) return undefined;\n\n const fn = resolveContentExtractor(s.extractContentPath);\n if (!fn && !warnedPaths.has(s.extractContentPath)) {\n warnedPaths.add(s.extractContentPath);\n console.warn(\n `[payload-plugin-seo] extractContentPath \"${s.extractContentPath}\" is not registered; falling back to the built-in extractor. Call registerContentExtractors from \"@focus-reactive/payload-plugin-seo/content\" in an admin-mounted client module.`\n );\n }\n return fn;\n })();\n\n return buildAnalysisInput({\n values: inputValues,\n locale: s.locale,\n payloadLocale: s.locale?.code,\n apiRoute: s.apiRoute,\n keyphrase: live ? s.keyphrase : s.debouncedKeyphrase,\n fields: s.fields,\n site: s.site,\n hostFields: s.hostFields,\n ctx: s.ctx,\n resolver: s.resolver,\n resolveDepth: s.resolveDepth,\n override,\n });\n },\n []\n );\n\n const invalidateMedia = useCallback(() => liveRef.current.resolver.invalidate(), []);\n\n return { signature, getInput, invalidateMedia };\n}\n"],"mappings":";AAEA,SAAS,kBAAkB,WAAW,aAAa,iBAAiB;AAEpE,SAAS,4BAA4B;AACrC,SAAS,aAAa,SAAS,cAAc;AAC7C,SAAS,+BAA+B;AACxC,SAAS,yBAAyB;AAIlC,SAAS,0BAA0B;AAEnC,MAAM,cAAc,oBAAI,IAAY;AAEpC,MAAM,cAAc;AAmBb,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA;AACF,GAAuC;AACrC,QAAM,CAAC,UAAU,IAAI,iBAAiB;AACtC,QAAM,SAAS,UAAU;AACzB,QAAM,EAAE,QAAQ,gBAAgB,IAAI,UAAU;AAE9C,QAAM,kBAAkB,YAAY,YAAY,WAAW;AAC3D,QAAM,qBAAqB,YAAY,WAAW,WAAW;AAE7D,QAAM,WAAW,OAAO,OAAO;AAC/B,QAAM,WAAW,QAAQ,MAAM,kBAAkB,QAAQ,GAAG,CAAC,QAAQ,CAAC;AAEtE,QAAM,YAAY;AAAA,IAChB,CAAC,SAAgC;AAC/B,YAAM,SAAS,gBAAgB,EAAE,gBAAgB,KAAc,CAAC;AAGhE,aAAO,QAAQ,UAAU,CAAC;AAAA,IAC5B;AAAA,IACA,CAAC,eAAe;AAAA,EAClB;AAEA,QAAM,aAAa;AAAA,IACjB,MAAM,UAAU,cAAc;AAAA,IAC9B,CAAC,WAAW,cAAc;AAAA,EAC5B;AAEA,QAAM,MAAM;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,KAAK,wBAAwB,EAAE,kBAAkB;AACvD,YAAI,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,kBAAkB,GAAG;AACjD,sBAAY,IAAI,EAAE,kBAAkB;AACpC,kBAAQ;AAAA,YACN,4CAA4C,EAAE,kBAAkB;AAAA,UAClE;AAAA,QACF;AACA,eAAO;AAAA,MACT,GAAG;AAEH,aAAO,mBAAmB;AAAA,QACxB,QAAQ;AAAA,QACR,QAAQ,EAAE;AAAA,QACV,eAAe,EAAE,QAAQ;AAAA,QACzB,UAAU,EAAE;AAAA,QACZ,WAAW,OAAO,EAAE,YAAY,EAAE;AAAA,QAClC,QAAQ,EAAE;AAAA,QACV,MAAM,EAAE;AAAA,QACR,YAAY,EAAE;AAAA,QACd,KAAK,EAAE;AAAA,QACP,UAAU,EAAE;AAAA,QACZ,cAAc,EAAE;AAAA,QAChB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,kBAAkB,YAAY,MAAM,QAAQ,QAAQ,SAAS,WAAW,GAAG,CAAC,CAAC;AAEnF,SAAO,EAAE,WAAW,UAAU,gBAAgB;AAChD;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/SeoDrawer/useLiveDocument.ts"],"sourcesContent":["\"use client\";\n\nimport { useAllFormFields, useConfig, useDebounce, useLocale } from \"@payloadcms/ui\";\nimport { reduceFieldsToValues } from \"payload/shared\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { resolveContentExtractor } from \"../../content/registry\";\nimport type { AnalysisInput } from \"../../engine/types/analysis\";\nimport type { SeoFieldPaths } from \"../../types/config\";\nimport { buildAnalysisInput } from \"./build-analysis-input\";\n\nconst erroredPaths = new Set<string>();\nconst DEBOUNCE_MS = 1000;\n\nexport interface LiveDocArgs {\n collectionSlug: string;\n fields: SeoFieldPaths;\n site: { name: string; baseUrl: string };\n keyphrase: string;\n enabled?: boolean;\n extractContentPath: string;\n}\n\nexport interface UseLiveDocumentResult {\n signature: string;\n getInput: (opts?: { live?: boolean }) => Promise<AnalysisInput>;\n}\n\nexport function useLiveDocument({\n collectionSlug: _collectionSlug,\n fields,\n site,\n keyphrase,\n enabled = true,\n extractContentPath,\n}: LiveDocArgs): UseLiveDocumentResult {\n const [formFields] = useAllFormFields();\n const locale = useLocale();\n const { config } = useConfig();\n\n const debouncedFields = useDebounce(formFields, DEBOUNCE_MS);\n const debouncedKeyphrase = useDebounce(keyphrase, DEBOUNCE_MS);\n const apiRoute = config.routes.api;\n\n const values = useMemo<Record<string, unknown>>(\n () => (enabled ? (reduceFieldsToValues(debouncedFields, true) as Record<string, unknown>) : {}),\n [enabled, debouncedFields]\n );\n\n const signature = useMemo(\n () => JSON.stringify({ values, keyphrase: debouncedKeyphrase, locale: locale?.code ?? null }),\n [values, debouncedKeyphrase, locale]\n );\n\n const liveRef = useRef({\n formFields,\n values,\n keyphrase,\n debouncedKeyphrase,\n locale,\n fields,\n site,\n extractContentPath,\n apiRoute,\n });\n liveRef.current = {\n formFields,\n values,\n keyphrase,\n debouncedKeyphrase,\n locale,\n fields,\n site,\n extractContentPath,\n apiRoute,\n };\n\n const getInput = useCallback(\n async ({ live = false }: { live?: boolean } = {}): Promise<AnalysisInput> => {\n const s = liveRef.current;\n const inputValues = live\n ? (reduceFieldsToValues(s.formFields, true) as Record<string, unknown>)\n : s.values;\n\n const extractor = resolveContentExtractor(s.extractContentPath);\n if (!extractor && !erroredPaths.has(s.extractContentPath)) {\n erroredPaths.add(s.extractContentPath);\n console.error(\n `[payload-plugin-seo] extractContentPath \"${s.extractContentPath}\" is not registered; content analysis will be empty. Call registerContentExtractors from \"@focus-reactive/payload-plugin-seo/content\" in an admin-mounted client module.`\n );\n }\n\n return buildAnalysisInput({\n values: inputValues,\n locale: s.locale,\n payloadLocale: s.locale?.code,\n apiRoute: s.apiRoute,\n keyphrase: live ? s.keyphrase : s.debouncedKeyphrase,\n fields: s.fields,\n site: s.site,\n extractor,\n });\n },\n []\n );\n\n return { signature, getInput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xC,EAAE;AAEN,YAAM,YAAY,wBAAwB,EAAE,kBAAkB;AAC9D,UAAI,CAAC,aAAa,CAAC,aAAa,IAAI,EAAE,kBAAkB,GAAG;AACzD,qBAAa,IAAI,EAAE,kBAAkB;AACrC,gBAAQ;AAAA,UACN,4CAA4C,EAAE,kBAAkB;AAAA,QAClE;AAAA,MACF;AAEA,aAAO,mBAAmB;AAAA,QACxB,QAAQ;AAAA,QACR,QAAQ,EAAE;AAAA,QACV,eAAe,EAAE,QAAQ;AAAA,QACzB,UAAU,EAAE;AAAA,QACZ,WAAW,OAAO,EAAE,YAAY,EAAE;AAAA,QAClC,QAAQ,EAAE;AAAA,QACV,MAAM,EAAE;AAAA,QACR;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,WAAW,SAAS;AAC/B;","names":[]}
@@ -1,5 +1,5 @@
1
- export { heading, paragraph, link, image, video, richText, html } from "./schema/helpers";
1
+ export { heading, paragraph, link, image, video, richText, html, compact } from "./schema/helpers";
2
2
  export type { ContentNode, HeadingLevel } from "./schema/nodes";
3
3
  export { registerContentExtractors, resolveContentExtractor } from "./registry";
4
- export type { ContentExtractor, ContentSelection, ExtractContext } from "../types/config";
4
+ export type { ContentExtractor, ExtractContext, ExtractToolkit, DocQuery, DocStore, ContentHelpers, } from "../types/config";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/content/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnG,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,cAAc,GACf,MAAM,iBAAiB,CAAC"}
@@ -1,6 +1,7 @@
1
- import { heading, paragraph, link, image, video, richText, html } from "./schema/helpers";
1
+ import { heading, paragraph, link, image, video, richText, html, compact } from "./schema/helpers";
2
2
  import { registerContentExtractors, resolveContentExtractor } from "./registry";
3
3
  export {
4
+ compact,
4
5
  heading,
5
6
  html,
6
7
  image,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/content/index.ts"],"sourcesContent":["export { heading, paragraph, link, image, video, richText, html } from \"./schema/helpers\";\nexport type { ContentNode, HeadingLevel } from \"./schema/nodes\";\nexport { registerContentExtractors, resolveContentExtractor } from \"./registry\";\nexport type { ContentExtractor, ContentSelection, ExtractContext } from \"../types/config\";\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,MAAM,OAAO,OAAO,UAAU,YAAY;AAEvE,SAAS,2BAA2B,+BAA+B;","names":[]}
1
+ {"version":3,"sources":["../../src/content/index.ts"],"sourcesContent":["export { heading, paragraph, link, image, video, richText, html, compact } from \"./schema/helpers\";\nexport type { ContentNode, HeadingLevel } from \"./schema/nodes\";\nexport { registerContentExtractors, resolveContentExtractor } from \"./registry\";\nexport type {\n ContentExtractor,\n ExtractContext,\n ExtractToolkit,\n DocQuery,\n DocStore,\n ContentHelpers,\n} from \"../types/config\";\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,MAAM,OAAO,OAAO,UAAU,MAAM,eAAe;AAEhF,SAAS,2BAA2B,+BAA+B;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { DocQuery, DocStore } from "../../types/config";
2
+ export declare function createResolveDocs(apiRoute: string | undefined, locale: string | undefined): (queries: DocQuery[]) => Promise<DocStore>;
3
+ //# sourceMappingURL=resolve-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-docs.d.ts","sourceRoot":"","sources":["../../../src/content/resolve/resolve-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAkD7D,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAc5C"}
@@ -0,0 +1,48 @@
1
+ function key(collection, id) {
2
+ return `${collection}:${id}`;
3
+ }
4
+ async function fetchQuery(apiRoute, query, locale) {
5
+ const ids = [...new Set(query.ids.map(String))];
6
+ if (ids.length === 0)
7
+ return [];
8
+ const params = new URLSearchParams({
9
+ depth: String(query.depth ?? 0),
10
+ limit: String(ids.length)
11
+ });
12
+ if (locale)
13
+ params.set("locale", locale);
14
+ ids.forEach((id, i) => params.set(`where[id][in][${i}]`, id));
15
+ for (const field of query.select ?? [])
16
+ params.set(`select[${field}]`, "true");
17
+ try {
18
+ const res = await fetch(`${apiRoute}/${query.collection}?${params.toString()}`, {
19
+ credentials: "include"
20
+ });
21
+ if (!res.ok)
22
+ return [];
23
+ const body = await res.json();
24
+ return (body.docs ?? []).filter(
25
+ (d) => typeof d.id === "string" || typeof d.id === "number"
26
+ ).map((d) => [key(query.collection, d.id), d]);
27
+ } catch {
28
+ return [];
29
+ }
30
+ }
31
+ function createResolveDocs(apiRoute, locale) {
32
+ return async function resolveDocs(queries) {
33
+ const store = /* @__PURE__ */ new Map();
34
+ if (apiRoute) {
35
+ const results = await Promise.all(queries.map((q) => fetchQuery(apiRoute, q, locale)));
36
+ for (const entries of results)
37
+ for (const [k, doc] of entries)
38
+ store.set(k, doc);
39
+ }
40
+ return {
41
+ get: (collection, id) => store.get(key(collection, id))
42
+ };
43
+ };
44
+ }
45
+ export {
46
+ createResolveDocs
47
+ };
48
+ //# sourceMappingURL=resolve-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/content/resolve/resolve-docs.ts"],"sourcesContent":["import type { DocQuery, DocStore } from \"../../types/config\";\n\ntype Doc = Record<string, unknown>;\n\ninterface FindResponse {\n docs?: Array<Doc & { id?: unknown }>;\n}\n\nfunction key(collection: string, id: string | number): string {\n return `${collection}:${id}`;\n}\n\nasync function fetchQuery(\n apiRoute: string,\n query: DocQuery,\n locale: string | undefined\n): Promise<Array<[string, Doc]>> {\n const ids = [...new Set(query.ids.map(String))];\n if (ids.length === 0) return [];\n\n const params = new URLSearchParams({\n depth: String(query.depth ?? 0),\n limit: String(ids.length),\n });\n\n if (locale) params.set(\"locale\", locale);\n\n ids.forEach((id, i) => params.set(`where[id][in][${i}]`, id));\n\n for (const field of query.select ?? []) params.set(`select[${field}]`, \"true\");\n\n try {\n const res = await fetch(`${apiRoute}/${query.collection}?${params.toString()}`, {\n credentials: \"include\",\n });\n if (!res.ok) return [];\n\n const body = (await res.json()) as FindResponse;\n\n return (body.docs ?? [])\n .filter(\n (d): d is Doc & { id: string | number } =>\n typeof d.id === \"string\" || typeof d.id === \"number\"\n )\n .map((d) => [key(query.collection, d.id), d] as [string, Doc]);\n } catch {\n return [];\n }\n}\n\nexport function createResolveDocs(\n apiRoute: string | undefined,\n locale: string | undefined\n): (queries: DocQuery[]) => Promise<DocStore> {\n return async function resolveDocs(queries: DocQuery[]): Promise<DocStore> {\n const store = new Map<string, Doc>();\n\n if (apiRoute) {\n const results = await Promise.all(queries.map((q) => fetchQuery(apiRoute, q, locale)));\n\n for (const entries of results) for (const [k, doc] of entries) store.set(k, doc);\n }\n\n return {\n get: (collection, id) => store.get(key(collection, id)),\n };\n };\n}\n"],"mappings":"AAQA,SAAS,IAAI,YAAoB,IAA6B;AAC5D,SAAO,GAAG,UAAU,IAAI,EAAE;AAC5B;AAEA,eAAe,WACb,UACA,OACA,QAC+B;AAC/B,QAAM,MAAM,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,IAAI,MAAM,CAAC,CAAC;AAC9C,MAAI,IAAI,WAAW;AAAG,WAAO,CAAC;AAE9B,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,OAAO,OAAO,MAAM,SAAS,CAAC;AAAA,IAC9B,OAAO,OAAO,IAAI,MAAM;AAAA,EAC1B,CAAC;AAED,MAAI;AAAQ,WAAO,IAAI,UAAU,MAAM;AAEvC,MAAI,QAAQ,CAAC,IAAI,MAAM,OAAO,IAAI,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAE5D,aAAW,SAAS,MAAM,UAAU,CAAC;AAAG,WAAO,IAAI,UAAU,KAAK,KAAK,MAAM;AAE7E,MAAI;AACF,UAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,IAAI,MAAM,UAAU,IAAI,OAAO,SAAS,CAAC,IAAI;AAAA,MAC9E,aAAa;AAAA,IACf,CAAC;AACD,QAAI,CAAC,IAAI;AAAI,aAAO,CAAC;AAErB,UAAM,OAAQ,MAAM,IAAI,KAAK;AAE7B,YAAQ,KAAK,QAAQ,CAAC,GACnB;AAAA,MACC,CAAC,MACC,OAAO,EAAE,OAAO,YAAY,OAAO,EAAE,OAAO;AAAA,IAChD,EACC,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,YAAY,EAAE,EAAE,GAAG,CAAC,CAAkB;AAAA,EACjE,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEO,SAAS,kBACd,UACA,QAC4C;AAC5C,SAAO,eAAe,YAAY,SAAwC;AACxE,UAAM,QAAQ,oBAAI,IAAiB;AAEnC,QAAI,UAAU;AACZ,YAAM,UAAU,MAAM,QAAQ,IAAI,QAAQ,IAAI,CAAC,MAAM,WAAW,UAAU,GAAG,MAAM,CAAC,CAAC;AAErF,iBAAW,WAAW;AAAS,mBAAW,CAAC,GAAG,GAAG,KAAK;AAAS,gBAAM,IAAI,GAAG,GAAG;AAAA,IACjF;AAEA,WAAO;AAAA,MACL,KAAK,CAAC,YAAY,OAAO,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;AAAA,IACxD;AAAA,EACF;AACF;","names":[]}
@@ -6,4 +6,5 @@ export declare function image(src?: string | null, alt?: string | null): Content
6
6
  export declare function video(src?: string | null, poster?: string | null): ContentNode | null;
7
7
  export declare function richText(value: unknown): ContentNode | null;
8
8
  export declare function html(raw?: string | null): ContentNode | null;
9
+ export declare function compact(nodes: (ContentNode | null | undefined)[]): ContentNode[];
9
10
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/content/schema/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAGrF;AAED,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAGlE;AAED,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAInF;AAED,wBAAgB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,CAAC,EAA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AAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAG5D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,WAAW,EAAE,CAEhF"}
@@ -48,7 +48,11 @@ function html(raw) {
48
48
  const r = clean(raw);
49
49
  return r ? { type: "html", html: r } : null;
50
50
  }
51
+ function compact(nodes) {
52
+ return nodes.filter((n) => n != null);
53
+ }
51
54
  export {
55
+ compact,
52
56
  heading,
53
57
  html,
54
58
  image,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/content/schema/helpers.ts"],"sourcesContent":["import { lexicalToHtml } from \"../lexicalToHtml\";\nimport type { ContentNode, HeadingLevel } from \"./nodes\";\n\nfunction clean(v?: string | null): string | undefined {\n if (typeof v !== \"string\") return undefined;\n const t = v.trim();\n return t ? v : undefined;\n}\n\nexport function heading(level: HeadingLevel, text?: string | null): ContentNode | null {\n const t = clean(text);\n return t ? { type: \"heading\", level, text: t } : null;\n}\n\nexport function paragraph(text?: string | null): ContentNode | null {\n const t = clean(text);\n return t ? { type: \"paragraph\", text: t } : null;\n}\n\nexport function link(href?: string | null, text?: string | null): ContentNode | null {\n const h = clean(href);\n const t = clean(text);\n return h && t ? { type: \"link\", href: h, text: t } : null;\n}\n\nexport function image(src?: string | null, alt?: string | null): ContentNode | null {\n const s = clean(src);\n return s ? { type: \"image\", src: s, alt: clean(alt) ?? \"\" } : null;\n}\n\nexport function video(src?: string | null, poster?: string | null): ContentNode | null {\n const s = clean(src);\n if (!s) return null;\n const p = clean(poster);\n return p ? { type: \"video\", src: s, poster: p } : { type: \"video\", src: s };\n}\n\nfunction hasLexicalContent(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null) return false;\n const root = (value as Record<string, unknown>).root;\n if (typeof root !== \"object\" || root === null) return false;\n const children = (root as Record<string, unknown>).children;\n return Array.isArray(children) && children.length > 0;\n}\n\nexport function richText(value: unknown): ContentNode | null {\n if (!hasLexicalContent(value)) return null;\n const out = lexicalToHtml(value as never);\n return out ? { type: \"html\", html: out } : null;\n}\n\nexport function html(raw?: string | null): ContentNode | null {\n const r = clean(raw);\n return r ? { type: \"html\", html: r } : null;\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAG9B,SAAS,MAAM,GAAuC;AACpD,MAAI,OAAO,MAAM;AAAU,WAAO;AAClC,QAAM,IAAI,EAAE,KAAK;AACjB,SAAO,IAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,OAAqB,MAA0C;AACrF,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,IAAI,EAAE,MAAM,WAAW,OAAO,MAAM,EAAE,IAAI;AACnD;AAEO,SAAS,UAAU,MAA0C;AAClE,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,IAAI,EAAE,MAAM,aAAa,MAAM,EAAE,IAAI;AAC9C;AAEO,SAAS,KAAK,MAAsB,MAA0C;AACnF,QAAM,IAAI,MAAM,IAAI;AACpB,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,KAAK,IAAI,EAAE,MAAM,QAAQ,MAAM,GAAG,MAAM,EAAE,IAAI;AACvD;AAEO,SAAS,MAAM,KAAqB,KAAyC;AAClF,QAAM,IAAI,MAAM,GAAG;AACnB,SAAO,IAAI,EAAE,MAAM,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,KAAK,GAAG,IAAI;AAChE;AAEO,SAAS,MAAM,KAAqB,QAA4C;AACrF,QAAM,IAAI,MAAM,GAAG;AACnB,MAAI,CAAC;AAAG,WAAO;AACf,QAAM,IAAI,MAAM,MAAM;AACtB,SAAO,IAAI,EAAE,MAAM,SAAS,KAAK,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,KAAK,EAAE;AAC5E;AAEA,SAAS,kBAAkB,OAAyB;AAClD,MAAI,OAAO,UAAU,YAAY,UAAU;AAAM,WAAO;AACxD,QAAM,OAAQ,MAAkC;AAChD,MAAI,OAAO,SAAS,YAAY,SAAS;AAAM,WAAO;AACtD,QAAM,WAAY,KAAiC;AACnD,SAAO,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AACtD;AAEO,SAAS,SAAS,OAAoC;AAC3D,MAAI,CAAC,kBAAkB,KAAK;AAAG,WAAO;AACtC,QAAM,MAAM,cAAc,KAAc;AACxC,SAAO,MAAM,EAAE,MAAM,QAAQ,MAAM,IAAI,IAAI;AAC7C;AAEO,SAAS,KAAK,KAAyC;AAC5D,QAAM,IAAI,MAAM,GAAG;AACnB,SAAO,IAAI,EAAE,MAAM,QAAQ,MAAM,EAAE,IAAI;AACzC;","names":[]}
1
+ {"version":3,"sources":["../../../src/content/schema/helpers.ts"],"sourcesContent":["import { lexicalToHtml } from \"../lexicalToHtml\";\nimport type { ContentNode, HeadingLevel } from \"./nodes\";\n\nfunction clean(v?: string | null): string | undefined {\n if (typeof v !== \"string\") return undefined;\n const t = v.trim();\n return t ? v : undefined;\n}\n\nexport function heading(level: HeadingLevel, text?: string | null): ContentNode | null {\n const t = clean(text);\n return t ? { type: \"heading\", level, text: t } : null;\n}\n\nexport function paragraph(text?: string | null): ContentNode | null {\n const t = clean(text);\n return t ? { type: \"paragraph\", text: t } : null;\n}\n\nexport function link(href?: string | null, text?: string | null): ContentNode | null {\n const h = clean(href);\n const t = clean(text);\n return h && t ? { type: \"link\", href: h, text: t } : null;\n}\n\nexport function image(src?: string | null, alt?: string | null): ContentNode | null {\n const s = clean(src);\n return s ? { type: \"image\", src: s, alt: clean(alt) ?? \"\" } : null;\n}\n\nexport function video(src?: string | null, poster?: string | null): ContentNode | null {\n const s = clean(src);\n if (!s) return null;\n const p = clean(poster);\n return p ? { type: \"video\", src: s, poster: p } : { type: \"video\", src: s };\n}\n\nfunction hasLexicalContent(value: unknown): boolean {\n if (typeof value !== \"object\" || value === null) return false;\n const root = (value as Record<string, unknown>).root;\n if (typeof root !== \"object\" || root === null) return false;\n const children = (root as Record<string, unknown>).children;\n return Array.isArray(children) && children.length > 0;\n}\n\nexport function richText(value: unknown): ContentNode | null {\n if (!hasLexicalContent(value)) return null;\n const out = lexicalToHtml(value as never);\n return out ? { type: \"html\", html: out } : null;\n}\n\nexport function html(raw?: string | null): ContentNode | null {\n const r = clean(raw);\n return r ? { type: \"html\", html: r } : null;\n}\n\nexport function compact(nodes: (ContentNode | null | undefined)[]): ContentNode[] {\n return nodes.filter((n): n is ContentNode => n != null);\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAG9B,SAAS,MAAM,GAAuC;AACpD,MAAI,OAAO,MAAM;AAAU,WAAO;AAClC,QAAM,IAAI,EAAE,KAAK;AACjB,SAAO,IAAI,IAAI;AACjB;AAEO,SAAS,QAAQ,OAAqB,MAA0C;AACrF,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,IAAI,EAAE,MAAM,WAAW,OAAO,MAAM,EAAE,IAAI;AACnD;AAEO,SAAS,UAAU,MAA0C;AAClE,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,IAAI,EAAE,MAAM,aAAa,MAAM,EAAE,IAAI;AAC9C;AAEO,SAAS,KAAK,MAAsB,MAA0C;AACnF,QAAM,IAAI,MAAM,IAAI;AACpB,QAAM,IAAI,MAAM,IAAI;AACpB,SAAO,KAAK,IAAI,EAAE,MAAM,QAAQ,MAAM,GAAG,MAAM,EAAE,IAAI;AACvD;AAEO,SAAS,MAAM,KAAqB,KAAyC;AAClF,QAAM,IAAI,MAAM,GAAG;AACnB,SAAO,IAAI,EAAE,MAAM,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,KAAK,GAAG,IAAI;AAChE;AAEO,SAAS,MAAM,KAAqB,QAA4C;AACrF,QAAM,IAAI,MAAM,GAAG;AACnB,MAAI,CAAC;AAAG,WAAO;AACf,QAAM,IAAI,MAAM,MAAM;AACtB,SAAO,IAAI,EAAE,MAAM,SAAS,KAAK,GAAG,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,KAAK,EAAE;AAC5E;AAEA,SAAS,kBAAkB,OAAyB;AAClD,MAAI,OAAO,UAAU,YAAY,UAAU;AAAM,WAAO;AACxD,QAAM,OAAQ,MAAkC;AAChD,MAAI,OAAO,SAAS,YAAY,SAAS;AAAM,WAAO;AACtD,QAAM,WAAY,KAAiC;AACnD,SAAO,MAAM,QAAQ,QAAQ,KAAK,SAAS,SAAS;AACtD;AAEO,SAAS,SAAS,OAAoC;AAC3D,MAAI,CAAC,kBAAkB,KAAK;AAAG,WAAO;AACtC,QAAM,MAAM,cAAc,KAAc;AACxC,SAAO,MAAM,EAAE,MAAM,QAAQ,MAAM,IAAI,IAAI;AAC7C;AAEO,SAAS,KAAK,KAAyC;AAC5D,QAAM,IAAI,MAAM,GAAG;AACnB,SAAO,IAAI,EAAE,MAAM,QAAQ,MAAM,EAAE,IAAI;AACzC;AAEO,SAAS,QAAQ,OAA0D;AAChF,SAAO,MAAM,OAAO,CAAC,MAAwB,KAAK,IAAI;AACxD;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { seoPlugin } from "./plugin";
2
- export type { ContentExtractor, SeoPluginConfig, SeoCollectionConfig, SeoFieldPaths, SeoSiteConfig, ContentSelection } from "./types/config";
2
+ export type { ContentExtractor, SeoPluginConfig, SeoCollectionConfig, SeoFieldPaths, SeoSiteConfig, } from "./types/config";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,aAAa,GACd,MAAM,gBAAgB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { seoPlugin } from \"./plugin\";\nexport type { ContentExtractor, SeoPluginConfig, SeoCollectionConfig, SeoFieldPaths, SeoSiteConfig, ContentSelection } from \"./types/config\";\n"],"mappings":"AAAA,SAAS,iBAAiB;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { seoPlugin } from \"./plugin\";\nexport type {\n ContentExtractor,\n SeoPluginConfig,\n SeoCollectionConfig,\n SeoFieldPaths,\n SeoSiteConfig,\n} from \"./types/config\";\n"],"mappings":"AAAA,SAAS,iBAAiB;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,SAAS,CAAC;AAG9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAOtD,eAAO,MAAM,SAAS,WACX,eAAe,KAAG,MAwB1B,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,SAAS,CAAC;AAG9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAOtD,eAAO,MAAM,SAAS,WACX,eAAe,KAAG,MA0C1B,CAAC"}
package/dist/plugin.js CHANGED
@@ -13,16 +13,31 @@ const seoPlugin = (config) => (incomingConfig) => {
13
13
  );
14
14
  return incomingConfig;
15
15
  }
16
- setPluginConfig(config);
16
+ const collections = config.collections.filter((c) => {
17
+ if (typeof c.extractContentPath === "string" && c.extractContentPath.trim())
18
+ return true;
19
+ console.warn(
20
+ `${PREFIX} Collection "${c.slug}" is missing a required extractContentPath; SEO analysis disabled for it.`
21
+ );
22
+ return false;
23
+ });
24
+ if (collections.length === 0) {
25
+ console.warn(
26
+ `${PREFIX} Disabled: no collection has a valid extractContentPath. Plugin not registered.`
27
+ );
28
+ return incomingConfig;
29
+ }
30
+ const effectiveConfig = { ...config, collections };
31
+ setPluginConfig(effectiveConfig);
17
32
  const merged = mergeTranslations(
18
33
  incomingConfig.i18n?.translations ?? {},
19
- mergeTranslations(en, config.translations ?? {})
34
+ mergeTranslations(en, effectiveConfig.translations ?? {})
20
35
  );
21
36
  const withTranslations = {
22
37
  ...incomingConfig,
23
38
  i18n: { ...incomingConfig.i18n, translations: merged }
24
39
  };
25
- return overrideAdmin(withTranslations, config);
40
+ return overrideAdmin(withTranslations, effectiveConfig);
26
41
  };
27
42
  export {
28
43
  seoPlugin
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config, Plugin } from \"payload\";\nimport { setPluginConfig } from \"./config\";\nimport { PLUGIN_NAME } from \"./constants\";\nimport type { SeoPluginConfig } from \"./types/config\";\nimport { overrideAdmin } from \"./utils/config/overrideAdmin\";\nimport { mergeTranslations } from \"./utils/config/mergeTranslations\";\nimport { en } from \"./translations/en\";\n\nconst PREFIX = `[${PLUGIN_NAME}]`;\n\nexport const seoPlugin =\n (config: SeoPluginConfig): Plugin =>\n (incomingConfig: Config): Config => {\n if (config.disabled) return incomingConfig;\n\n if (!config.collections?.length) {\n console.warn(\n `${PREFIX} Disabled: config.collections must list at least one collection slug. Plugin not registered.`\n );\n return incomingConfig;\n }\n\n setPluginConfig(config);\n\n const merged = mergeTranslations(\n (incomingConfig.i18n?.translations as never) ?? {},\n mergeTranslations(en, config.translations ?? {})\n );\n\n const withTranslations: Config = {\n ...incomingConfig,\n i18n: { ...incomingConfig.i18n, translations: merged as never },\n };\n\n return overrideAdmin(withTranslations, config);\n };\n"],"mappings":"AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAE5B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,UAAU;AAEnB,MAAM,SAAS,IAAI,WAAW;AAEvB,MAAM,YACX,CAAC,WACD,CAAC,mBAAmC;AAClC,MAAI,OAAO;AAAU,WAAO;AAE5B,MAAI,CAAC,OAAO,aAAa,QAAQ;AAC/B,YAAQ;AAAA,MACN,GAAG,MAAM;AAAA,IACX;AACA,WAAO;AAAA,EACT;AAEA,kBAAgB,MAAM;AAEtB,QAAM,SAAS;AAAA,IACZ,eAAe,MAAM,gBAA0B,CAAC;AAAA,IACjD,kBAAkB,IAAI,OAAO,gBAAgB,CAAC,CAAC;AAAA,EACjD;AAEA,QAAM,mBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,MAAM,EAAE,GAAG,eAAe,MAAM,cAAc,OAAgB;AAAA,EAChE;AAEA,SAAO,cAAc,kBAAkB,MAAM;AAC/C;","names":[]}
1
+ {"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config, Plugin } from \"payload\";\nimport { setPluginConfig } from \"./config\";\nimport { PLUGIN_NAME } from \"./constants\";\nimport type { SeoPluginConfig } from \"./types/config\";\nimport { overrideAdmin } from \"./utils/config/overrideAdmin\";\nimport { mergeTranslations } from \"./utils/config/mergeTranslations\";\nimport { en } from \"./translations/en\";\n\nconst PREFIX = `[${PLUGIN_NAME}]`;\n\nexport const seoPlugin =\n (config: SeoPluginConfig): Plugin =>\n (incomingConfig: Config): Config => {\n if (config.disabled) return incomingConfig;\n\n if (!config.collections?.length) {\n console.warn(\n `${PREFIX} Disabled: config.collections must list at least one collection slug. Plugin not registered.`\n );\n return incomingConfig;\n }\n\n const collections = config.collections.filter((c) => {\n if (typeof c.extractContentPath === \"string\" && c.extractContentPath.trim()) return true;\n\n console.warn(\n `${PREFIX} Collection \"${c.slug}\" is missing a required extractContentPath; SEO analysis disabled for it.`\n );\n\n return false;\n });\n\n if (collections.length === 0) {\n console.warn(\n `${PREFIX} Disabled: no collection has a valid extractContentPath. Plugin not registered.`\n );\n return incomingConfig;\n }\n\n const effectiveConfig: SeoPluginConfig = { ...config, collections };\n setPluginConfig(effectiveConfig);\n\n const merged = mergeTranslations(\n (incomingConfig.i18n?.translations as never) ?? {},\n mergeTranslations(en, effectiveConfig.translations ?? {})\n );\n\n const withTranslations: Config = {\n ...incomingConfig,\n i18n: { ...incomingConfig.i18n, translations: merged as never },\n };\n\n return overrideAdmin(withTranslations, effectiveConfig);\n };\n"],"mappings":"AACA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAE5B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,UAAU;AAEnB,MAAM,SAAS,IAAI,WAAW;AAEvB,MAAM,YACX,CAAC,WACD,CAAC,mBAAmC;AAClC,MAAI,OAAO;AAAU,WAAO;AAE5B,MAAI,CAAC,OAAO,aAAa,QAAQ;AAC/B,YAAQ;AAAA,MACN,GAAG,MAAM;AAAA,IACX;AACA,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,OAAO,YAAY,OAAO,CAAC,MAAM;AACnD,QAAI,OAAO,EAAE,uBAAuB,YAAY,EAAE,mBAAmB,KAAK;AAAG,aAAO;AAEpF,YAAQ;AAAA,MACN,GAAG,MAAM,gBAAgB,EAAE,IAAI;AAAA,IACjC;AAEA,WAAO;AAAA,EACT,CAAC;AAED,MAAI,YAAY,WAAW,GAAG;AAC5B,YAAQ;AAAA,MACN,GAAG,MAAM;AAAA,IACX;AACA,WAAO;AAAA,EACT;AAEA,QAAM,kBAAmC,EAAE,GAAG,QAAQ,YAAY;AAClE,kBAAgB,eAAe;AAE/B,QAAM,SAAS;AAAA,IACZ,eAAe,MAAM,gBAA0B,CAAC;AAAA,IACjD,kBAAkB,IAAI,gBAAgB,gBAAgB,CAAC,CAAC;AAAA,EAC1D;AAEA,QAAM,mBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,MAAM,EAAE,GAAG,eAAe,MAAM,cAAc,OAAgB;AAAA,EAChE;AAEA,SAAO,cAAc,kBAAkB,eAAe;AACxD;","names":[]}
@@ -1,4 +1,4 @@
1
- import type { ContentNode } from "../content/schema/nodes";
1
+ import type { ContentNode, HeadingLevel } from "../content/schema/nodes";
2
2
  import type { Translations } from "../translations/types";
3
3
  /** Runtime context handed to a content extractor so it can resolve references and locale-correct hrefs. */
4
4
  export interface ExtractContext {
@@ -7,17 +7,10 @@ export interface ExtractContext {
7
7
  /** Payload REST API route (e.g. "/api") for client-side reference fetches. */
8
8
  apiRoute?: string;
9
9
  }
10
- /** Client extractor: receives hydrated, unflattened form values + runtime context, returns the content schema (Intermediate Representation). */
11
- export type ContentExtractor = (values: Record<string, unknown>, ctx?: ExtractContext) => ContentNode[] | Promise<ContentNode[]>;
12
- /** Which parts of the document the built-in extractor walks. */
13
- export interface ContentSelection {
14
- /** Dot-paths to walk, in order. Omitted or empty = whole document root. */
15
- include?: string[];
16
- /** Dot-paths to skip (merged with auto-excluded seoTitle/metaDescription/slug). */
17
- exclude?: string[];
18
- }
10
+ /** Developer-authored extractor: raw form values + runtime ctx + injected toolkit → content schema (Intermediate Representation). */
11
+ export type ContentExtractor = (values: Record<string, unknown>, ctx: ExtractContext, toolkit: ExtractToolkit) => ContentNode[] | Promise<ContentNode[]>;
19
12
  export interface SeoFieldPaths {
20
- /** Dot-path to the SEO title. Falls back to the collection useAsTitle / `title` if absent. */
13
+ /** Dot-path to the SEO title. Falls back to `title` if absent. */
21
14
  seoTitle?: string;
22
15
  /** Dot-path to the meta description. Absent → meta-desc checks disabled + snippet has no description. */
23
16
  metaDescription?: string;
@@ -26,26 +19,16 @@ export interface SeoFieldPaths {
26
19
  * @default "slug"
27
20
  */
28
21
  slug?: string;
29
- /**
30
- * Built-in content selection. A string is a single field path.
31
- * An object selects include/exclude paths over the whole document.
32
- * Ignored when `extractContentPath` is set and registered.
33
- */
34
- content?: string | ContentSelection;
35
22
  }
36
23
  export interface SeoCollectionConfig {
37
24
  slug: string;
38
25
  fields?: SeoFieldPaths;
39
26
  /**
40
- * importMap path string used as the lookup key for a registered ContentExtractor (returns ContentNode[]).
41
- * Register the function via registerContentExtractors from "@focus-reactive/payload-plugin-seo/content".
42
- */
43
- extractContentPath?: string;
44
- /**
45
- * Depth of nested relation/upload resolution for the built-in extractor.
46
- * @default 2
27
+ * importMap path string used as the lookup key for a registered ContentExtractor.
28
+ * Register the function via registerContentExtractors from
29
+ * "@focus-reactive/payload-plugin-seo/content" in an admin-mounted client module.
47
30
  */
48
- resolveDepth?: number;
31
+ extractContentPath: string;
49
32
  }
50
33
  export interface SeoSiteConfig {
51
34
  name?: string;
@@ -59,4 +42,31 @@ export interface SeoPluginConfig {
59
42
  supportedLocales?: string[];
60
43
  translations?: Translations;
61
44
  }
45
+ export interface DocQuery {
46
+ collection: string;
47
+ ids: (string | number)[];
48
+ /** Payload field-projection: only these top-level fields are returned. */
49
+ select?: string[];
50
+ /** Payload relationship-population depth.
51
+ * @default 0
52
+ */
53
+ depth?: number;
54
+ }
55
+ export interface DocStore {
56
+ get(collection: string, id: string | number): Record<string, unknown> | undefined;
57
+ }
58
+ export interface ContentHelpers {
59
+ heading: (level: HeadingLevel, text?: string | null) => ContentNode | null;
60
+ paragraph: (text?: string | null) => ContentNode | null;
61
+ link: (href?: string | null, text?: string | null) => ContentNode | null;
62
+ image: (src?: string | null, alt?: string | null) => ContentNode | null;
63
+ video: (src?: string | null, poster?: string | null) => ContentNode | null;
64
+ html: (raw?: string | null) => ContentNode | null;
65
+ richText: (value: unknown) => ContentNode | null;
66
+ compact: (nodes: (ContentNode | null | undefined)[]) => ContentNode[];
67
+ }
68
+ export interface ExtractToolkit {
69
+ resolveDocs: (queries: DocQuery[]) => Promise<DocStore>;
70
+ helpers: ContentHelpers;
71
+ }
62
72
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KA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GAAG,IAAI,CAAC;IAClD,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,WAAW,GAAG,IAAI,CAAC;IACjD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,KAAK,WAAW,EAAE,CAAC;CACvE;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxD,OAAO,EAAE,cAAc,CAAC;CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"overrideAdmin.d.ts","sourceRoot":"","sources":["../../../src/utils/config/overrideAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,oBAAoB,CAAC;AAQzE,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CA4CrF"}
1
+ {"version":3,"file":"overrideAdmin.d.ts","sourceRoot":"","sources":["../../../src/utils/config/overrideAdmin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,oBAAoB,CAAC;AAEzE,wBAAgB,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CAyCrF"}
@@ -1,13 +1,7 @@
1
1
  import { getComponentPath } from "./getComponentPath";
2
- function normalizeDepth(depth) {
3
- if (depth === void 0)
4
- return 2;
5
- return Number.isFinite(depth) && depth >= 0 ? Math.floor(depth) : 0;
6
- }
7
2
  function overrideAdmin(incomingConfig, config) {
8
3
  const bySlug = new Map(config.collections.map((c) => [c.slug, c]));
9
4
  const site = config.site ?? {};
10
- const slugPaths = Object.fromEntries(config.collections.map((c) => [c.slug, c.fields?.slug ?? "slug"]));
11
5
  const collections = (incomingConfig.collections ?? []).map((collection) => {
12
6
  const seoCfg = bySlug.get(collection.slug);
13
7
  if (!seoCfg)
@@ -17,15 +11,13 @@ function overrideAdmin(incomingConfig, config) {
17
11
  clientProps: {
18
12
  collectionSlug: collection.slug,
19
13
  fields: seoCfg.fields ?? {},
20
- extractContentPath: seoCfg.extractContentPath ?? null,
14
+ extractContentPath: seoCfg.extractContentPath,
21
15
  site: {
22
16
  name: site.name ?? "",
23
17
  baseUrl: site.baseUrl ?? "",
24
18
  faviconUrl: site.faviconUrl ?? ""
25
19
  },
26
- supportedLocales: config.supportedLocales ?? ["en"],
27
- resolveDepth: normalizeDepth(seoCfg.resolveDepth),
28
- slugPaths
20
+ supportedLocales: config.supportedLocales ?? ["en"]
29
21
  }
30
22
  };
31
23
  const existing = collection.admin?.components?.edit?.beforeDocumentControls ?? [];