@prenta/plugin-seo 0.1.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 (108) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/LICENSE +21 -0
  3. package/README.md +29 -0
  4. package/dist/__tests__/audit-fixes.test.d.ts +2 -0
  5. package/dist/__tests__/audit-fixes.test.d.ts.map +1 -0
  6. package/dist/__tests__/audit-fixes.test.js +162 -0
  7. package/dist/__tests__/audit-fixes.test.js.map +1 -0
  8. package/dist/__tests__/canonical.test.d.ts +2 -0
  9. package/dist/__tests__/canonical.test.d.ts.map +1 -0
  10. package/dist/__tests__/canonical.test.js +67 -0
  11. package/dist/__tests__/canonical.test.js.map +1 -0
  12. package/dist/__tests__/hooks.test.d.ts +2 -0
  13. package/dist/__tests__/hooks.test.d.ts.map +1 -0
  14. package/dist/__tests__/hooks.test.js +106 -0
  15. package/dist/__tests__/hooks.test.js.map +1 -0
  16. package/dist/__tests__/index.test.d.ts +2 -0
  17. package/dist/__tests__/index.test.d.ts.map +1 -0
  18. package/dist/__tests__/index.test.js +43 -0
  19. package/dist/__tests__/index.test.js.map +1 -0
  20. package/dist/__tests__/link-health.test.d.ts +2 -0
  21. package/dist/__tests__/link-health.test.d.ts.map +1 -0
  22. package/dist/__tests__/link-health.test.js +140 -0
  23. package/dist/__tests__/link-health.test.js.map +1 -0
  24. package/dist/__tests__/og-image.test.d.ts +2 -0
  25. package/dist/__tests__/og-image.test.d.ts.map +1 -0
  26. package/dist/__tests__/og-image.test.js +45 -0
  27. package/dist/__tests__/og-image.test.js.map +1 -0
  28. package/dist/__tests__/robots.test.d.ts +2 -0
  29. package/dist/__tests__/robots.test.d.ts.map +1 -0
  30. package/dist/__tests__/robots.test.js +27 -0
  31. package/dist/__tests__/robots.test.js.map +1 -0
  32. package/dist/__tests__/schema-composer.test.d.ts +2 -0
  33. package/dist/__tests__/schema-composer.test.d.ts.map +1 -0
  34. package/dist/__tests__/schema-composer.test.js +47 -0
  35. package/dist/__tests__/schema-composer.test.js.map +1 -0
  36. package/dist/__tests__/schema-validator.test.d.ts +2 -0
  37. package/dist/__tests__/schema-validator.test.d.ts.map +1 -0
  38. package/dist/__tests__/schema-validator.test.js +129 -0
  39. package/dist/__tests__/schema-validator.test.js.map +1 -0
  40. package/dist/__tests__/sitemap.test.d.ts +2 -0
  41. package/dist/__tests__/sitemap.test.d.ts.map +1 -0
  42. package/dist/__tests__/sitemap.test.js +196 -0
  43. package/dist/__tests__/sitemap.test.js.map +1 -0
  44. package/dist/admin/GooglePreview.d.ts +9 -0
  45. package/dist/admin/GooglePreview.d.ts.map +1 -0
  46. package/dist/admin/GooglePreview.js +68 -0
  47. package/dist/admin/GooglePreview.js.map +1 -0
  48. package/dist/admin/SEOPanel.d.ts +11 -0
  49. package/dist/admin/SEOPanel.d.ts.map +1 -0
  50. package/dist/admin/SEOPanel.js +76 -0
  51. package/dist/admin/SEOPanel.js.map +1 -0
  52. package/dist/admin/SchemaPreview.d.ts +7 -0
  53. package/dist/admin/SchemaPreview.d.ts.map +1 -0
  54. package/dist/admin/SchemaPreview.js +93 -0
  55. package/dist/admin/SchemaPreview.js.map +1 -0
  56. package/dist/canonical/index.d.ts +16 -0
  57. package/dist/canonical/index.d.ts.map +1 -0
  58. package/dist/canonical/index.js +77 -0
  59. package/dist/canonical/index.js.map +1 -0
  60. package/dist/collections.d.ts +3 -0
  61. package/dist/collections.d.ts.map +1 -0
  62. package/dist/collections.js +2 -0
  63. package/dist/collections.js.map +1 -0
  64. package/dist/fields.d.ts +3 -0
  65. package/dist/fields.d.ts.map +1 -0
  66. package/dist/fields.js +115 -0
  67. package/dist/fields.js.map +1 -0
  68. package/dist/hooks.d.ts +15 -0
  69. package/dist/hooks.d.ts.map +1 -0
  70. package/dist/hooks.js +20 -0
  71. package/dist/hooks.js.map +1 -0
  72. package/dist/index.d.ts +59 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +37 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/link-health/index.d.ts +48 -0
  77. package/dist/link-health/index.d.ts.map +1 -0
  78. package/dist/link-health/index.js +171 -0
  79. package/dist/link-health/index.js.map +1 -0
  80. package/dist/og-image/index.d.ts +11 -0
  81. package/dist/og-image/index.d.ts.map +1 -0
  82. package/dist/og-image/index.js +28 -0
  83. package/dist/og-image/index.js.map +1 -0
  84. package/dist/robots/index.d.ts +14 -0
  85. package/dist/robots/index.d.ts.map +1 -0
  86. package/dist/robots/index.js +45 -0
  87. package/dist/robots/index.js.map +1 -0
  88. package/dist/schema/auto-detect.d.ts +3 -0
  89. package/dist/schema/auto-detect.d.ts.map +1 -0
  90. package/dist/schema/auto-detect.js +3 -0
  91. package/dist/schema/auto-detect.js.map +1 -0
  92. package/dist/schema/composer.d.ts +15 -0
  93. package/dist/schema/composer.d.ts.map +1 -0
  94. package/dist/schema/composer.js +82 -0
  95. package/dist/schema/composer.js.map +1 -0
  96. package/dist/schema/registry.d.ts +170 -0
  97. package/dist/schema/registry.d.ts.map +1 -0
  98. package/dist/schema/registry.js +2 -0
  99. package/dist/schema/registry.js.map +1 -0
  100. package/dist/schema/validator.d.ts +23 -0
  101. package/dist/schema/validator.d.ts.map +1 -0
  102. package/dist/schema/validator.js +148 -0
  103. package/dist/schema/validator.js.map +1 -0
  104. package/dist/sitemap/index.d.ts +110 -0
  105. package/dist/sitemap/index.d.ts.map +1 -0
  106. package/dist/sitemap/index.js +228 -0
  107. package/dist/sitemap/index.js.map +1 -0
  108. package/package.json +43 -0
@@ -0,0 +1,93 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from 'react';
4
+ /** Renders a formatted JSON-LD preview with visual type indicators. */
5
+ export function SchemaPreview({ schema }) {
6
+ const formatted = useMemo(() => formatJsonLd(schema), [schema]);
7
+ const schemaType = schema['@type'] ?? 'Unknown';
8
+ const isValid = Boolean(schema['@context'] && schema['@type']);
9
+ return (_jsxs("div", { style: { fontFamily: 'system-ui, sans-serif', padding: '16px' }, children: [_jsxs("div", { style: {
10
+ display: 'flex',
11
+ alignItems: 'center',
12
+ justifyContent: 'space-between',
13
+ marginBottom: '12px',
14
+ }, children: [_jsx("h3", { style: { margin: 0, fontSize: '14px', fontWeight: 600 }, children: "Structured Data Preview" }), _jsx("span", { style: {
15
+ fontSize: '12px',
16
+ padding: '2px 8px',
17
+ borderRadius: '9999px',
18
+ background: isValid ? '#dcfce7' : '#fee2e2',
19
+ color: isValid ? '#166534' : '#991b1b',
20
+ fontWeight: 500,
21
+ }, children: isValid ? 'Valid' : 'Invalid' })] }), _jsxs("div", { style: {
22
+ fontSize: '12px',
23
+ color: '#6b7280',
24
+ marginBottom: '8px',
25
+ }, children: ["Type: ", _jsx("strong", { children: schemaType })] }), _jsx("div", { style: {
26
+ background: '#1e1e1e',
27
+ borderRadius: '8px',
28
+ padding: '16px',
29
+ overflow: 'auto',
30
+ maxHeight: '400px',
31
+ }, children: _jsx("pre", { style: { margin: 0, fontSize: '13px', lineHeight: '20px', color: '#d4d4d4' }, children: _jsx("code", { children: formatted.map((segment, i) => (_jsx("span", { style: { color: segment.color }, children: segment.text }, i))) }) }) }), _jsxs("div", { style: { marginTop: '12px', fontSize: '12px', color: '#9ca3af' }, children: ["Embed as", ' ', _jsx("code", { style: {
32
+ background: '#f3f4f6',
33
+ padding: '1px 4px',
34
+ borderRadius: '3px',
35
+ fontSize: '11px',
36
+ }, children: '<script type="application/ld+json">' })] })] }));
37
+ }
38
+ function formatJsonLd(obj, indent = 0) {
39
+ const segments = [];
40
+ const pad = ' '.repeat(indent);
41
+ const innerPad = ' '.repeat(indent + 1);
42
+ if (obj === null || obj === undefined) {
43
+ segments.push({ text: 'null', color: '#569cd6' });
44
+ return segments;
45
+ }
46
+ if (typeof obj === 'string') {
47
+ segments.push({ text: `"${obj}"`, color: '#ce9178' });
48
+ return segments;
49
+ }
50
+ if (typeof obj === 'number' || typeof obj === 'boolean') {
51
+ segments.push({ text: String(obj), color: '#b5cea8' });
52
+ return segments;
53
+ }
54
+ if (Array.isArray(obj)) {
55
+ if (obj.length === 0) {
56
+ segments.push({ text: '[]', color: '#d4d4d4' });
57
+ return segments;
58
+ }
59
+ segments.push({ text: '[\n', color: '#d4d4d4' });
60
+ obj.forEach((item, i) => {
61
+ segments.push({ text: innerPad, color: '#d4d4d4' });
62
+ segments.push(...formatJsonLd(item, indent + 1));
63
+ if (i < obj.length - 1)
64
+ segments.push({ text: ',', color: '#d4d4d4' });
65
+ segments.push({ text: '\n', color: '#d4d4d4' });
66
+ });
67
+ segments.push({ text: `${pad}]`, color: '#d4d4d4' });
68
+ return segments;
69
+ }
70
+ if (typeof obj === 'object') {
71
+ const entries = Object.entries(obj);
72
+ if (entries.length === 0) {
73
+ segments.push({ text: '{}', color: '#d4d4d4' });
74
+ return segments;
75
+ }
76
+ segments.push({ text: '{\n', color: '#d4d4d4' });
77
+ entries.forEach(([key, value], i) => {
78
+ const keyColor = key.startsWith('@') ? '#c586c0' : '#9cdcfe';
79
+ segments.push({ text: innerPad, color: '#d4d4d4' });
80
+ segments.push({ text: `"${key}"`, color: keyColor });
81
+ segments.push({ text: ': ', color: '#d4d4d4' });
82
+ segments.push(...formatJsonLd(value, indent + 1));
83
+ if (i < entries.length - 1)
84
+ segments.push({ text: ',', color: '#d4d4d4' });
85
+ segments.push({ text: '\n', color: '#d4d4d4' });
86
+ });
87
+ segments.push({ text: `${pad}}`, color: '#d4d4d4' });
88
+ return segments;
89
+ }
90
+ segments.push({ text: String(obj), color: '#d4d4d4' });
91
+ return segments;
92
+ }
93
+ //# sourceMappingURL=SchemaPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaPreview.js","sourceRoot":"","sources":["../../src/admin/SchemaPreview.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAMtC,uEAAuE;AACvE,MAAM,UAAU,a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AAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;YAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;QACjD,CAAC,CAAC,CAAA;QACF,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;QACpD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;IACtD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface DuplicateGroup {
2
+ urls: string[];
3
+ similarity: number;
4
+ suggestedCanonical?: string;
5
+ }
6
+ /**
7
+ * Compares pages by content similarity and groups near-duplicates.
8
+ * Uses a simple hash-based similarity metric on normalized text.
9
+ */
10
+ export declare function detectDuplicates(pages: Array<{
11
+ url: string;
12
+ content: string;
13
+ }>): DuplicateGroup[];
14
+ /** Selects the best canonical URL from a group of duplicates. */
15
+ export declare function suggestCanonical(duplicates: DuplicateGroup): string;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canonical/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,cAAc,EAAE,CAmCjG;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CAanE"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Compares pages by content similarity and groups near-duplicates.
3
+ * Uses a simple hash-based similarity metric on normalized text.
4
+ */
5
+ export function detectDuplicates(pages) {
6
+ const groups = [];
7
+ const assigned = new Set();
8
+ for (let i = 0; i < pages.length; i++) {
9
+ if (assigned.has(i))
10
+ continue;
11
+ const pageI = pages[i];
12
+ const group = [pageI.url];
13
+ let maxSimilarity = 0;
14
+ for (let j = i + 1; j < pages.length; j++) {
15
+ if (assigned.has(j))
16
+ continue;
17
+ const pageJ = pages[j];
18
+ const sim = computeSimilarity(pageI.content, pageJ.content);
19
+ if (sim >= 0.85) {
20
+ group.push(pageJ.url);
21
+ assigned.add(j);
22
+ maxSimilarity = Math.max(maxSimilarity, sim);
23
+ }
24
+ }
25
+ if (group.length > 1) {
26
+ assigned.add(i);
27
+ const canonical = suggestCanonical({ urls: group, similarity: maxSimilarity });
28
+ groups.push({
29
+ urls: group,
30
+ similarity: maxSimilarity,
31
+ suggestedCanonical: canonical,
32
+ });
33
+ }
34
+ }
35
+ return groups;
36
+ }
37
+ /** Selects the best canonical URL from a group of duplicates. */
38
+ export function suggestCanonical(duplicates) {
39
+ const ranked = [...duplicates.urls].sort((a, b) => {
40
+ const depthA = a.split('/').filter(Boolean).length;
41
+ const depthB = b.split('/').filter(Boolean).length;
42
+ if (depthA !== depthB)
43
+ return depthA - depthB;
44
+ if (a.includes('?') && !b.includes('?'))
45
+ return 1;
46
+ if (!a.includes('?') && b.includes('?'))
47
+ return -1;
48
+ return a.length - b.length;
49
+ });
50
+ return ranked[0] ?? '';
51
+ }
52
+ function computeSimilarity(a, b) {
53
+ const tokensA = normalize(a);
54
+ const tokensB = normalize(b);
55
+ if (tokensA.length === 0 && tokensB.length === 0)
56
+ return 1;
57
+ if (tokensA.length === 0 || tokensB.length === 0)
58
+ return 0;
59
+ const setA = new Set(tokensA);
60
+ const setB = new Set(tokensB);
61
+ let intersection = 0;
62
+ for (const token of setA) {
63
+ if (setB.has(token))
64
+ intersection++;
65
+ }
66
+ return (2 * intersection) / (setA.size + setB.size);
67
+ }
68
+ function normalize(content) {
69
+ return content
70
+ .replace(/<[^>]+>/g, ' ')
71
+ .replace(/\s+/g, ' ')
72
+ .trim()
73
+ .toLowerCase()
74
+ .split(' ')
75
+ .filter((t) => t.length > 2);
76
+ }
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/canonical/index.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA8C;IAC7E,MAAM,MAAM,GAAqB,EAAE,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,SAAQ;QAE7B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACvB,MAAM,KAAK,GAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,aAAa,GAAG,CAAC,CAAA;QAErB,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,SAAQ;YAE7B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;YACvB,MAAM,GAAG,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;YAC3D,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;gBAChB,KAAK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,MAAM,GAAG,CAAC,CAAC,CAAA;AAChC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CollectionDefinition } from '@prenta/core';
2
+ export declare const seoCollections: Record<string, CollectionDefinition>;
3
+ //# sourceMappingURL=collections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const seoCollections = {};
2
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAyC,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { FieldDefinition } from '@prenta/core';
2
+ export declare const seoFields: Record<string, FieldDefinition>;
3
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAqHrD,CAAA"}
package/dist/fields.js ADDED
@@ -0,0 +1,115 @@
1
+ export const seoFields = {
2
+ metaTitle: {
3
+ type: 'text',
4
+ label: 'Meta Title',
5
+ maxLength: 70,
6
+ admin: {
7
+ position: 'sidebar',
8
+ description: 'Recommended length: 50–60 characters. Displayed in browser tabs and search results.',
9
+ },
10
+ },
11
+ metaDescription: {
12
+ type: 'text',
13
+ label: 'Meta Description',
14
+ maxLength: 160,
15
+ admin: {
16
+ position: 'sidebar',
17
+ description: 'Recommended length: 120–155 characters. Appears below the title in search results.',
18
+ },
19
+ },
20
+ canonicalUrl: {
21
+ type: 'url',
22
+ label: 'Canonical URL',
23
+ admin: {
24
+ position: 'sidebar',
25
+ description: 'Set a canonical URL to prevent duplicate content issues. Leave blank to use the page URL.',
26
+ },
27
+ },
28
+ ogImage: {
29
+ type: 'media',
30
+ label: 'OG Image',
31
+ accept: ['image/png', 'image/jpeg', 'image/webp'],
32
+ admin: {
33
+ position: 'sidebar',
34
+ description: 'Recommended size: 1200×630px. Displayed when shared on social platforms.',
35
+ },
36
+ },
37
+ ogTitle: {
38
+ type: 'text',
39
+ label: 'OG Title',
40
+ maxLength: 70,
41
+ admin: {
42
+ position: 'sidebar',
43
+ description: 'Overrides the meta title for social sharing. Falls back to Meta Title if empty.',
44
+ },
45
+ },
46
+ ogDescription: {
47
+ type: 'text',
48
+ label: 'OG Description',
49
+ maxLength: 200,
50
+ admin: {
51
+ position: 'sidebar',
52
+ description: 'Overrides the meta description for social sharing.',
53
+ },
54
+ },
55
+ twitterCard: {
56
+ type: 'select',
57
+ label: 'Twitter Card',
58
+ options: [
59
+ { label: 'Summary', value: 'summary' },
60
+ { label: 'Summary Large Image', value: 'summary_large_image' },
61
+ { label: 'App', value: 'app' },
62
+ { label: 'Player', value: 'player' },
63
+ ],
64
+ admin: {
65
+ position: 'sidebar',
66
+ description: 'Controls the card style when shared on Twitter/X.',
67
+ },
68
+ },
69
+ robotsNoindex: {
70
+ type: 'boolean',
71
+ label: 'No Index',
72
+ defaultValue: false,
73
+ admin: {
74
+ position: 'sidebar',
75
+ description: 'Prevent search engines from indexing this page.',
76
+ },
77
+ },
78
+ robotsNofollow: {
79
+ type: 'boolean',
80
+ label: 'No Follow',
81
+ defaultValue: false,
82
+ admin: {
83
+ position: 'sidebar',
84
+ description: 'Prevent search engines from following links on this page.',
85
+ },
86
+ },
87
+ structuredDataType: {
88
+ type: 'select',
89
+ label: 'Structured Data Type',
90
+ options: [
91
+ { label: 'Article', value: 'Article' },
92
+ { label: 'Web Page', value: 'WebPage' },
93
+ { label: 'Person', value: 'Person' },
94
+ { label: 'Event', value: 'Event' },
95
+ { label: 'FAQ Page', value: 'FAQPage' },
96
+ { label: 'Service', value: 'Service' },
97
+ { label: 'Job Posting', value: 'JobPosting' },
98
+ { label: 'Local Business', value: 'LocalBusiness' },
99
+ { label: 'Review', value: 'Review' },
100
+ { label: 'Product', value: 'Product' },
101
+ ],
102
+ admin: {
103
+ position: 'sidebar',
104
+ description: 'Schema.org type for structured data. Auto-detected from collection if not set.',
105
+ },
106
+ },
107
+ structuredDataOverrides: {
108
+ type: 'json',
109
+ label: 'Structured Data Overrides',
110
+ admin: {
111
+ description: 'Manual JSON-LD overrides merged into the auto-generated structured data.',
112
+ },
113
+ },
114
+ };
115
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAoC;IACxD,SAAS,EAAE;QACT,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,YAAY;QACnB,SAAS,EAAE,EAAE;QACb,KAAK,EAAE;YACL,QAAQ,EAAE,SAAS;YACnB,WAAW,EACT,qFAAqF;SACxF;KACF;IACD,eAAe,EAAE;QACf,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,kBAAkB;QACzB,SAAS,EAAE,GAAG;QACd,KAAK,EAAE;YACL,QAAQ,EAAE,SAAS;YACnB,WAAW,EACT,oFAAoF;SACvF;KACF;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,eAAe;QACtB,KAAK,EAAE;YACL,QAAQ,EAAE,SAAS;YACnB,WAAW,EACT,2FAA2F;SAC9F;KACF;IACD,OAAO,EAAE;QACP,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC;QACjD,KAAK,EAAE;YACL,QAAQ,EA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K,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;YACtC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE;YACvC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;YACpC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAClC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE;YACvC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;YACtC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,YAAY,EAAE;YAC7C,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,EAAE;YACnD,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;YACpC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;SACvC;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,SAAS;YACnB,WAAW,EAAE,gFAAgF;SAC9F;KACF;IACD,uBAAuB,EAAE;QACvB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,2BAA2B;QAClC,KAAK,EAAE;YACL,WAAW,EAAE,0EAA0E;SACxF;KACF;CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Plugin lifecycle hooks.
3
+ *
4
+ * Schema defaults and structured-data stamping are handled in cms-core
5
+ * (`prepareContentStructuredData` on document create/update). Hooks here are
6
+ * limited to cache invalidation side effects.
7
+ *
8
+ * These hooks use the shared `PluginHook` contract from cms-core: each handler
9
+ * receives a single typed payload. For document-lifecycle events the top-level
10
+ * `collection` identifies the collection; field values live under
11
+ * `payload.data`.
12
+ */
13
+ import type { PluginHook } from '@prenta/core';
14
+ export declare const seoHooks: PluginHook[];
15
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAA;AAEzE,eAAO,MAAM,QAAQ,EAAE,UAAU,EAoBhC,CAAA"}
package/dist/hooks.js ADDED
@@ -0,0 +1,20 @@
1
+ export const seoHooks = [
2
+ {
3
+ // `afterUpdate` is a dispatched document-lifecycle event. When a document
4
+ // changes we drop its cached sitemap fragment so the next request rebuilds.
5
+ event: 'afterUpdate',
6
+ handler: async (payload) => {
7
+ if (!payload)
8
+ return;
9
+ const doc = payload;
10
+ // The collection lives at the top level of the payload (NOT in
11
+ // `payload.data`, and NOT under a `_collection` field).
12
+ const cacheKey = `sitemap:${doc.collection ?? 'global'}`;
13
+ if (typeof globalThis !== 'undefined') {
14
+ const cache = globalThis.__sitemapCache;
15
+ cache?.delete(cacheKey);
16
+ }
17
+ },
18
+ },
19
+ ];
20
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC;QACE,0EAA0E;QAC1E,4EAA4E;QAC5E,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACzB,IAAI,CAAC,OAAO;gBAAE,OAAM;YACpB,MAAM,GAAG,GAAG,OAAoC,CAAA;YAEhD,+DAA+D;YAC/D,wDAAwD;YACxD,MAAM,QAAQ,GAAG,WAAW,GAAG,CAAC,UAAU,IAAI,QAAQ,EAAE,CAAA;YACxD,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;gBACtC,MAAM,KAAK,GAAI,UAAsC,CAAC,cAEzC,CAAA;gBACb,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;KACF;CACF,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { type PluginDefinition } from '@prenta/core/config';
2
+ export interface SEOPluginConfig {
3
+ sitemap?: {
4
+ enabled?: boolean;
5
+ excludeCollections?: string[];
6
+ changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
7
+ defaultPriority?: number;
8
+ };
9
+ robots?: {
10
+ enabled?: boolean;
11
+ blockAIBots?: boolean;
12
+ additionalRules?: Array<{
13
+ userAgent: string;
14
+ allow?: string[];
15
+ disallow?: string[];
16
+ }>;
17
+ };
18
+ ogImage?: {
19
+ enabled?: boolean;
20
+ defaultTheme?: 'light' | 'dark';
21
+ siteName?: string;
22
+ };
23
+ linkHealth?: {
24
+ enabled?: boolean;
25
+ checkInterval?: number;
26
+ };
27
+ structuredData?: {
28
+ enabled?: boolean;
29
+ defaultOrganization?: {
30
+ name: string;
31
+ url: string;
32
+ logo?: string;
33
+ };
34
+ };
35
+ }
36
+ /** Creates an SEO plugin instance for Prenta CMS. */
37
+ export declare function seoPlugin(config?: SEOPluginConfig): PluginDefinition;
38
+ export { seoFields } from './fields.js';
39
+ export { seoCollections } from './collections.js';
40
+ export { seoHooks } from './hooks.js';
41
+ export { detectSchemaType } from './schema/auto-detect.js';
42
+ export { composeSchema, composeAndValidateSchema } from './schema/composer.js';
43
+ export { validateSchema, validateSchemaGraph } from './schema/validator.js';
44
+ export type { ValidationResult } from './schema/validator.js';
45
+ export { generateSitemapIndex, generateCollectionSitemap, generateImageSitemap, generateVideoSitemap, generateNewsSitemap, generateHreflangSitemap, buildDocumentUrl, SITEMAP_MAX_URLS, SITEMAP_MAX_BYTES, } from './sitemap/index.js';
46
+ export type { SitemapEntry, ImageSitemapEntry, VideoSitemapEntry, NewsSitemapEntry, HreflangEntry, CollectionSitemapConfig, } from './sitemap/index.js';
47
+ export { generateRobotsTxt } from './robots/index.js';
48
+ export type { RobotsConfig } from './robots/index.js';
49
+ export { generateOGImage } from './og-image/index.js';
50
+ export type { OGImageOptions } from './og-image/index.js';
51
+ export { detectBrokenLinks, detectOrphanPages, detectRedirectChains, MAX_LINKS, } from './link-health/index.js';
52
+ export type { LinkHealthResult, RedirectChain } from './link-health/index.js';
53
+ export { detectDuplicates, suggestCanonical } from './canonical/index.js';
54
+ export type { DuplicateGroup } from './canonical/index.js';
55
+ export { SEOPanel } from './admin/SEOPanel.js';
56
+ export { GooglePreview } from './admin/GooglePreview.js';
57
+ export { SchemaPreview } from './admin/SchemaPreview.js';
58
+ export type { SchemaOrgThing, SchemaOrgArticle, SchemaOrgPerson, SchemaOrgOrganization, SchemaOrgWebPage, SchemaOrgEvent, SchemaOrgFAQPage, SchemaOrgService, SchemaOrgJobPosting, SchemaOrgLocalBusiness, SchemaOrgReview, SchemaOrgProduct, } from './schema/registry.js';
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAKzE,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;QAC7B,eAAe,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;QAC3F,eAAe,CAAC,EAAE,MAAM,CAAA;KACzB,CAAA;IACD,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,WAAW,CAAC,EAAE,OAAO,CAAA;QACrB,eAAe,CAAC,EAAE,KAAK,CAAC;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;YAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC,CAAA;KACtF,CAAA;IACD,OAAO,CAAC,EA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EAAE,MAAM,mBAAmB,CAAA;AACrD,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,GACV,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ import { definePlugin } from '@prenta/core/config';
2
+ import { seoFields } from './fields.js';
3
+ import { seoCollections } from './collections.js';
4
+ import { seoHooks } from './hooks.js';
5
+ /** Creates an SEO plugin instance for Prenta CMS. */
6
+ export function seoPlugin(config = {}) {
7
+ return definePlugin({
8
+ name: 'plugin-seo',
9
+ fields: { ...seoFields },
10
+ collections: { ...seoCollections },
11
+ // A single entry into the SEO Operations Center. Sitemap and Link Health are
12
+ // TABS inside that hub (Technical / Links), not separate destinations — listing
13
+ // them here duplicated the tab bar in the sidebar with mismatched labels. Deep
14
+ // links to /seo/sitemap and /seo/link-health still resolve (cms-admin's
15
+ // seoTabForPath) for bookmarks; they're just no longer sidebar items.
16
+ adminNavItems: [{ label: 'SEO', icon: 'search', path: '/seo' }],
17
+ hooks: seoHooks.map((hook) => ({
18
+ ...hook,
19
+ _pluginConfig: config,
20
+ })),
21
+ });
22
+ }
23
+ export { seoFields } from './fields.js';
24
+ export { seoCollections } from './collections.js';
25
+ export { seoHooks } from './hooks.js';
26
+ export { detectSchemaType } from './schema/auto-detect.js';
27
+ export { composeSchema, composeAndValidateSchema } from './schema/composer.js';
28
+ export { validateSchema, validateSchemaGraph } from './schema/validator.js';
29
+ export { generateSitemapIndex, generateCollectionSitemap, generateImageSitemap, generateVideoSitemap, generateNewsSitemap, generateHreflangSitemap, buildDocumentUrl, SITEMAP_MAX_URLS, SITEMAP_MAX_BYTES, } from './sitemap/index.js';
30
+ export { generateRobotsTxt } from './robots/index.js';
31
+ export { generateOGImage } from './og-image/index.js';
32
+ export { detectBrokenLinks, detectOrphanPages, detectRedirectChains, MAX_LINKS, } from './link-health/index.js';
33
+ export { detectDuplicates, suggestCanonical } from './canonical/index.js';
34
+ export { SEOPanel } from './admin/SEOPanel.js';
35
+ export { GooglePreview } from './admin/GooglePreview.js';
36
+ export { SchemaPreview } from './admin/SchemaPreview.js';
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyB,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAiCrC,qDAAqD;AACrD,MAAM,UAAU,SAAS,CAAC,SAA0B,EAAE;IACpD,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,EAAE,GAAG,SAAS,EAAE;QACxB,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Aa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA"}
@@ -0,0 +1,48 @@
1
+ export interface LinkHealthResult {
2
+ url: string;
3
+ status: 'ok' | 'broken' | 'redirect' | 'timeout' | 'error' | 'blocked' | 'unverifiable';
4
+ statusCode?: number;
5
+ redirectTarget?: string;
6
+ responseTime?: number;
7
+ source: string;
8
+ }
9
+ export interface RedirectChain {
10
+ initialUrl: string;
11
+ /** Whether this is a terminating multi-hop chain or a cyclic redirect loop. */
12
+ kind: 'chain' | 'loop';
13
+ chain: string[];
14
+ finalUrl: string;
15
+ length: number;
16
+ }
17
+ /** Hard cap on the number of unique links checked per scan (DoS / fan-out guard). */
18
+ export declare const MAX_LINKS = 200;
19
+ /**
20
+ * Scans HTML content for links and checks their health.
21
+ *
22
+ * Outbound requests go through cms-core's `safeFetch` (DNS-resolving SSRF
23
+ * preflight + `redirect: 'manual'`) so a link to an internal/loopback/metadata
24
+ * address can't be used to probe the host. Scans are capped at {@link MAX_LINKS}
25
+ * unique URLs and run with bounded concurrency, each under a hard timeout.
26
+ *
27
+ * Probes use GET + a browser-like User-Agent (many hosts reject HEAD). First-party
28
+ * Vercel Blob media URLs are skipped. 3xx is reported as `redirect` (healthy);
29
+ * 403/405/429/999 as `unverifiable` (bot-walled), not `broken`.
30
+ */
31
+ export declare function detectBrokenLinks(content: string, baseUrl: string): Promise<LinkHealthResult[]>;
32
+ /** Finds pages that are not linked from any other page. */
33
+ export declare function detectOrphanPages(allPages: string[], linkedPages: string[]): string[];
34
+ /**
35
+ * Detects multi-hop redirect chains and cyclic redirect loops.
36
+ *
37
+ * A terminating sequence of 2+ redirects (3+ nodes) is a `chain`. A sequence
38
+ * that revisits an earlier node is a `loop` — reported separately because loops
39
+ * cause infinite-redirect crawl errors, whereas chains merely waste crawl
40
+ * budget. Mirrors cms-core's `detectChainsAndLoops`: each loop is reported once
41
+ * (all its members are marked handled) and sub-chains are collapsed into the
42
+ * longest chain from their entry point.
43
+ */
44
+ export declare function detectRedirectChains(redirects: Array<{
45
+ from: string;
46
+ to: string;
47
+ }>): RedirectChain[];
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/link-health/index.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,cAAc,CAAA;IACvF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,+EAA+E;IAC/E,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAID,qFAAqF;AACrF,eAAO,MAAM,SAAS,MAAM,CAAA;AA2B5B;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA0E7B;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAGrF;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7C,aAAa,EAAE,CAiDjB"}