@hagicode/hagilight-core 0.1.0-dev.148.1.e0c630e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Analytics51LA.astro +17 -0
- package/Copyright.astro +9 -0
- package/Footer.astro +208 -0
- package/FooterAvatarPicker.astro +9 -0
- package/FooterBrand.astro +339 -0
- package/GoogleAnalytics.astro +30 -0
- package/PostHog.astro +11 -0
- package/PromotoBanner.astro +582 -0
- package/README.md +485 -0
- package/RootTransit.astro +599 -0
- package/assets/footer/avatar.avif +0 -0
- package/assets/footer/avatar.webp +0 -0
- package/assets/footer/manifest.json +237 -0
- package/data/comparison-articles/de-DE/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/de-DE/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/pi-vs-hagicode.json +282 -0
- package/data/comparison-articles/de-DE/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/de-DE/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/en-US/claude-vs-hagicode.json +346 -0
- package/data/comparison-articles/en-US/codebuddy-vs-hagicode.json +322 -0
- package/data/comparison-articles/en-US/codex-vs-hagicode.json +321 -0
- package/data/comparison-articles/en-US/copilot-vs-hagicode.json +320 -0
- package/data/comparison-articles/en-US/deepagents-vs-hagicode.json +323 -0
- package/data/comparison-articles/en-US/dsh-vs-hagicode.json +323 -0
- package/data/comparison-articles/en-US/gemini-vs-hagicode.json +320 -0
- package/data/comparison-articles/en-US/hermes-vs-hagicode.json +323 -0
- package/data/comparison-articles/en-US/junie-vs-hagicode.json +323 -0
- package/data/comparison-articles/en-US/kimi-vs-hagicode.json +319 -0
- package/data/comparison-articles/en-US/kiro-vs-hagicode.json +319 -0
- package/data/comparison-articles/en-US/omp-vs-hagicode.json +345 -0
- package/data/comparison-articles/en-US/opencode-vs-hagicode.json +333 -0
- package/data/comparison-articles/en-US/pi-vs-hagicode.json +345 -0
- package/data/comparison-articles/en-US/qoder-vs-hagicode.json +323 -0
- package/data/comparison-articles/en-US/reasonix-vs-hagicode.json +344 -0
- package/data/comparison-articles/es-ES/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/es-ES/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/es-ES/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/es-ES/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/fr-FR/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/fr-FR/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/fr-FR/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/fr-FR/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/ja-JP/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/ja-JP/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/ja-JP/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/ja-JP/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/ko-KR/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/ko-KR/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/ko-KR/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/ko-KR/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/pt-BR/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/pt-BR/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/pt-BR/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/pt-BR/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/ru-RU/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/ru-RU/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/ru-RU/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/ru-RU/qoder-vs-hagicode.json +323 -0
- package/data/comparison-articles/ru-RU/reasonix-vs-hagicode.json +281 -0
- package/data/comparison-articles/zh-CN/claude-vs-hagicode.json +346 -0
- package/data/comparison-articles/zh-CN/codebuddy-vs-hagicode.json +322 -0
- package/data/comparison-articles/zh-CN/codex-vs-hagicode.json +321 -0
- package/data/comparison-articles/zh-CN/copilot-vs-hagicode.json +320 -0
- package/data/comparison-articles/zh-CN/deepagents-vs-hagicode.json +323 -0
- package/data/comparison-articles/zh-CN/dsh-vs-hagicode.json +323 -0
- package/data/comparison-articles/zh-CN/gemini-vs-hagicode.json +320 -0
- package/data/comparison-articles/zh-CN/hermes-vs-hagicode.json +323 -0
- package/data/comparison-articles/zh-CN/junie-vs-hagicode.json +323 -0
- package/data/comparison-articles/zh-CN/kimi-vs-hagicode.json +319 -0
- package/data/comparison-articles/zh-CN/kiro-vs-hagicode.json +319 -0
- package/data/comparison-articles/zh-CN/omp-vs-hagicode.json +345 -0
- package/data/comparison-articles/zh-CN/opencode-vs-hagicode.json +333 -0
- package/data/comparison-articles/zh-CN/pi-vs-hagicode.json +345 -0
- package/data/comparison-articles/zh-CN/qoder-vs-hagicode.json +323 -0
- package/data/comparison-articles/zh-CN/reasonix-vs-hagicode.json +344 -0
- package/data/comparison-articles/zh-Hant/claude-vs-hagicode.json +294 -0
- package/data/comparison-articles/zh-Hant/codebuddy-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/codex-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/copilot-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/deepagents-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/gemini-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/hermes-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/kimi-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/kiro-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/opencode-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/pi-vs-hagicode.json +281 -0
- package/data/comparison-articles/zh-Hant/qoder-vs-hagicode.json +266 -0
- package/data/comparison-articles/zh-Hant/reasonix-vs-hagicode.json +281 -0
- package/dist/analytics-events.d.ts +49 -0
- package/dist/analytics-events.js +113 -0
- package/dist/build-info-resolver.d.ts +8 -0
- package/dist/build-info-resolver.js +29 -0
- package/dist/build-info.d.ts +19 -0
- package/dist/build-info.js +60 -0
- package/dist/comparison-articles-source.d.ts +13 -0
- package/dist/comparison-articles-source.js +58 -0
- package/dist/comparison-articles.d.ts +127 -0
- package/dist/comparison-articles.js +260 -0
- package/dist/content-images.d.ts +126 -0
- package/dist/content-images.js +490 -0
- package/dist/favicon.d.ts +21 -0
- package/dist/favicon.js +27 -0
- package/dist/footer-avatar.d.ts +39 -0
- package/dist/footer-avatar.js +42 -0
- package/dist/footer-brand.d.ts +29 -0
- package/dist/footer-brand.js +86 -0
- package/dist/head.d.ts +7 -0
- package/dist/head.js +1 -0
- package/dist/link-policy.d.ts +33 -0
- package/dist/link-policy.js +93 -0
- package/dist/links.d.ts +70 -0
- package/dist/links.js +425 -0
- package/dist/posthog.d.ts +6 -0
- package/dist/posthog.js +17 -0
- package/dist/promotions.d.ts +50 -0
- package/dist/promotions.js +243 -0
- package/dist/promoto-banner.d.ts +14 -0
- package/dist/promoto-banner.js +499 -0
- package/dist/random-image.d.ts +69 -0
- package/dist/random-image.js +133 -0
- package/dist/related-sites.json +378 -0
- package/dist/root-transit.d.ts +12 -0
- package/dist/root-transit.js +221 -0
- package/dist/rss-footer-context.d.ts +6 -0
- package/dist/rss-footer-context.js +54 -0
- package/dist/rss-ownership.d.ts +26 -0
- package/dist/rss-ownership.js +63 -0
- package/dist/rss.d.ts +34 -0
- package/dist/rss.js +145 -0
- package/dist/seo-schema.d.ts +12 -0
- package/dist/seo-schema.js +20 -0
- package/dist/seo.d.ts +78 -0
- package/dist/seo.js +270 -0
- package/dist/site-metadata-ownership.d.ts +40 -0
- package/dist/site-metadata-ownership.js +72 -0
- package/dist/site-metadata-writer.d.ts +25 -0
- package/dist/site-metadata-writer.js +55 -0
- package/dist/site-metadata.d.ts +113 -0
- package/dist/site-metadata.js +256 -0
- package/dist/splash-images.d.ts +75 -0
- package/dist/splash-images.js +186 -0
- package/favicon.ico +0 -0
- package/logo.png +0 -0
- package/package.json +172 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export declare const STRUCTURED_ARTICLE_SCHEMA_VERSION = "1.0.0";
|
|
2
|
+
export declare const STRUCTURED_ARTICLE_CATEGORY = "vs-hagicode";
|
|
3
|
+
export interface StructuredArticleSeo {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export interface StructuredArticleCtaLink {
|
|
8
|
+
label: string;
|
|
9
|
+
href: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StructuredArticleRichTextBlock {
|
|
12
|
+
id: string;
|
|
13
|
+
type: 'rich-text';
|
|
14
|
+
content: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface StructuredArticleBulletListBlock {
|
|
17
|
+
id: string;
|
|
18
|
+
type: 'bullet-list';
|
|
19
|
+
items: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface StructuredArticleCapabilityItem {
|
|
22
|
+
id: string;
|
|
23
|
+
title: string;
|
|
24
|
+
content: string[];
|
|
25
|
+
bullets?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface StructuredArticleCapabilityListBlock {
|
|
28
|
+
id: string;
|
|
29
|
+
type: 'capability-list';
|
|
30
|
+
items: StructuredArticleCapabilityItem[];
|
|
31
|
+
}
|
|
32
|
+
export interface StructuredArticleComparisonItem {
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
agent: string;
|
|
36
|
+
hagicode: string;
|
|
37
|
+
combinedValue?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface StructuredArticleComparisonGridBlock {
|
|
40
|
+
id: string;
|
|
41
|
+
type: 'comparison-grid';
|
|
42
|
+
items: StructuredArticleComparisonItem[];
|
|
43
|
+
}
|
|
44
|
+
export interface StructuredArticleCalloutBlock {
|
|
45
|
+
id: string;
|
|
46
|
+
type: 'callout';
|
|
47
|
+
tone: 'info' | 'success' | 'warning';
|
|
48
|
+
title?: string;
|
|
49
|
+
content: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface StructuredArticleComparisonTableRow {
|
|
52
|
+
id: string;
|
|
53
|
+
/** One entry per header, in header order. The first entry is the row label. */
|
|
54
|
+
cells: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface StructuredArticleComparisonTableBlock {
|
|
57
|
+
id: string;
|
|
58
|
+
type: 'comparison-table';
|
|
59
|
+
caption?: string;
|
|
60
|
+
/** Column headers. The first one labels the row-label column. */
|
|
61
|
+
headers: string[];
|
|
62
|
+
rows: StructuredArticleComparisonTableRow[];
|
|
63
|
+
}
|
|
64
|
+
export interface StructuredArticleCtaGroupBlock {
|
|
65
|
+
id: string;
|
|
66
|
+
type: 'cta-group';
|
|
67
|
+
items: Array<StructuredArticleCtaLink & {
|
|
68
|
+
variant?: 'primary' | 'secondary';
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
export type StructuredArticleBlock = StructuredArticleRichTextBlock | StructuredArticleBulletListBlock | StructuredArticleCapabilityListBlock | StructuredArticleComparisonGridBlock | StructuredArticleComparisonTableBlock | StructuredArticleCalloutBlock | StructuredArticleCtaGroupBlock;
|
|
72
|
+
export interface StructuredArticleSection {
|
|
73
|
+
id: string;
|
|
74
|
+
title: string;
|
|
75
|
+
blocks: StructuredArticleBlock[];
|
|
76
|
+
}
|
|
77
|
+
export interface StructuredArticleFaqItem {
|
|
78
|
+
question: string;
|
|
79
|
+
answer: string;
|
|
80
|
+
}
|
|
81
|
+
export interface StructuredArticleDetail {
|
|
82
|
+
schemaVersion: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
category: string;
|
|
85
|
+
locale: string;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
seo: StructuredArticleSeo;
|
|
88
|
+
summary: string;
|
|
89
|
+
sections: StructuredArticleSection[];
|
|
90
|
+
/** Visible FAQ entries; also emitted as FAQPage structured data by the consuming site. */
|
|
91
|
+
faq?: StructuredArticleFaqItem[];
|
|
92
|
+
cta?: {
|
|
93
|
+
primary?: StructuredArticleCtaLink;
|
|
94
|
+
secondary?: StructuredArticleCtaLink;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export interface StructuredArticleLocaleManifestEntry {
|
|
98
|
+
slug: string;
|
|
99
|
+
category: string;
|
|
100
|
+
path: string;
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
title: string;
|
|
103
|
+
summary: string;
|
|
104
|
+
}
|
|
105
|
+
export interface StructuredArticleLocaleManifest {
|
|
106
|
+
schemaVersion: string;
|
|
107
|
+
locale: string;
|
|
108
|
+
generatedAt: string;
|
|
109
|
+
articles: StructuredArticleLocaleManifestEntry[];
|
|
110
|
+
}
|
|
111
|
+
export interface StructuredArticleRootManifestEntry {
|
|
112
|
+
locale: string;
|
|
113
|
+
path: string;
|
|
114
|
+
updatedAt: string;
|
|
115
|
+
}
|
|
116
|
+
export interface StructuredArticleRootManifest {
|
|
117
|
+
schemaVersion: string;
|
|
118
|
+
generatedAt: string;
|
|
119
|
+
localeIndexes: StructuredArticleRootManifestEntry[];
|
|
120
|
+
}
|
|
121
|
+
export declare function validateStructuredArticleDetail(detail: unknown, sourceLabel?: string): StructuredArticleDetail;
|
|
122
|
+
export declare function buildStructuredArticleDetailPath(locale: string, slug: string): string;
|
|
123
|
+
export declare function buildStructuredArticleLocaleManifestPath(locale: string): string;
|
|
124
|
+
/** Builds one locale manifest from details that are already loaded and validated. */
|
|
125
|
+
export declare function buildStructuredArticleLocaleManifestFromDetails(locale: string, details: readonly StructuredArticleDetail[]): StructuredArticleLocaleManifest;
|
|
126
|
+
/** Builds the root manifest from locale manifests that were built from loaded details. */
|
|
127
|
+
export declare function buildStructuredArticleRootManifestFromLocaleManifests(localeManifests: readonly StructuredArticleLocaleManifest[]): StructuredArticleRootManifest;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Browser-safe contract for the comparison article data in @hagicode/hagilight-core.
|
|
2
|
+
// Node-only loaders that read the packaged JSON live in ./comparison-articles-source.ts.
|
|
3
|
+
// Keep this module free of node: imports so browser bundles can use it.
|
|
4
|
+
export const STRUCTURED_ARTICLE_SCHEMA_VERSION = '1.0.0';
|
|
5
|
+
export const STRUCTURED_ARTICLE_CATEGORY = 'vs-hagicode';
|
|
6
|
+
function assert(condition, message) {
|
|
7
|
+
if (!condition) {
|
|
8
|
+
throw new Error(message);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function isRecord(value) {
|
|
12
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function assertNonEmptyString(value, fieldName) {
|
|
15
|
+
assert(typeof value === 'string' && value.trim().length > 0, `${fieldName} must be a non-empty string.`);
|
|
16
|
+
return value.trim();
|
|
17
|
+
}
|
|
18
|
+
function assertStringArray(value, fieldName) {
|
|
19
|
+
assert(Array.isArray(value) && value.length > 0, `${fieldName} must be a non-empty array.`);
|
|
20
|
+
return value.map((entry, index) => assertNonEmptyString(entry, `${fieldName}[${index}]`));
|
|
21
|
+
}
|
|
22
|
+
function assertCtaLink(value, fieldName) {
|
|
23
|
+
assert(isRecord(value), `${fieldName} must be an object.`);
|
|
24
|
+
return {
|
|
25
|
+
label: assertNonEmptyString(value.label, `${fieldName}.label`),
|
|
26
|
+
href: assertNonEmptyString(value.href, `${fieldName}.href`),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function ensureUnique(ids, fieldName) {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
for (const id of ids) {
|
|
32
|
+
assert(!seen.has(id), `${fieldName} contains duplicate id ${id}.`);
|
|
33
|
+
seen.add(id);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function validateStructuredArticleBlock(block, fieldName) {
|
|
37
|
+
assert(isRecord(block), `${fieldName} must be an object.`);
|
|
38
|
+
const id = assertNonEmptyString(block.id, `${fieldName}.id`);
|
|
39
|
+
const type = assertNonEmptyString(block.type, `${fieldName}.type`);
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 'rich-text':
|
|
42
|
+
return {
|
|
43
|
+
id,
|
|
44
|
+
type,
|
|
45
|
+
content: assertStringArray(block.content, `${fieldName}.content`),
|
|
46
|
+
};
|
|
47
|
+
case 'bullet-list':
|
|
48
|
+
return {
|
|
49
|
+
id,
|
|
50
|
+
type,
|
|
51
|
+
items: assertStringArray(block.items, `${fieldName}.items`),
|
|
52
|
+
};
|
|
53
|
+
case 'capability-list': {
|
|
54
|
+
assert(Array.isArray(block.items) && block.items.length > 0, `${fieldName}.items must be a non-empty array.`);
|
|
55
|
+
const items = block.items.map((item, index) => {
|
|
56
|
+
const itemField = `${fieldName}.items[${index}]`;
|
|
57
|
+
assert(isRecord(item), `${itemField} must be an object.`);
|
|
58
|
+
return {
|
|
59
|
+
id: assertNonEmptyString(item.id, `${itemField}.id`),
|
|
60
|
+
title: assertNonEmptyString(item.title, `${itemField}.title`),
|
|
61
|
+
content: assertStringArray(item.content, `${itemField}.content`),
|
|
62
|
+
...(item.bullets === undefined
|
|
63
|
+
? {}
|
|
64
|
+
: { bullets: assertStringArray(item.bullets, `${itemField}.bullets`) }),
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
ensureUnique(items.map((item) => item.id), `${fieldName}.items`);
|
|
68
|
+
return {
|
|
69
|
+
id,
|
|
70
|
+
type,
|
|
71
|
+
items,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
case 'comparison-grid': {
|
|
75
|
+
assert(Array.isArray(block.items) && block.items.length > 0, `${fieldName}.items must be a non-empty array.`);
|
|
76
|
+
const items = block.items.map((item, index) => {
|
|
77
|
+
const itemField = `${fieldName}.items[${index}]`;
|
|
78
|
+
assert(isRecord(item), `${itemField} must be an object.`);
|
|
79
|
+
return {
|
|
80
|
+
id: assertNonEmptyString(item.id, `${itemField}.id`),
|
|
81
|
+
label: assertNonEmptyString(item.label, `${itemField}.label`),
|
|
82
|
+
agent: assertNonEmptyString(item.agent, `${itemField}.agent`),
|
|
83
|
+
hagicode: assertNonEmptyString(item.hagicode, `${itemField}.hagicode`),
|
|
84
|
+
...(item.combinedValue === undefined
|
|
85
|
+
? {}
|
|
86
|
+
: { combinedValue: assertNonEmptyString(item.combinedValue, `${itemField}.combinedValue`) }),
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
ensureUnique(items.map((item) => item.id), `${fieldName}.items`);
|
|
90
|
+
return {
|
|
91
|
+
id,
|
|
92
|
+
type,
|
|
93
|
+
items,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
case 'comparison-table': {
|
|
97
|
+
const headers = assertStringArray(block.headers, `${fieldName}.headers`);
|
|
98
|
+
assert(headers.length >= 2, `${fieldName}.headers must contain at least two columns.`);
|
|
99
|
+
assert(Array.isArray(block.rows) && block.rows.length > 0, `${fieldName}.rows must be a non-empty array.`);
|
|
100
|
+
const rows = block.rows.map((row, index) => {
|
|
101
|
+
const rowField = `${fieldName}.rows[${index}]`;
|
|
102
|
+
assert(isRecord(row), `${rowField} must be an object.`);
|
|
103
|
+
const cells = assertStringArray(row.cells, `${rowField}.cells`);
|
|
104
|
+
assert(cells.length === headers.length, `${rowField}.cells must have ${headers.length} entries, one per header.`);
|
|
105
|
+
return {
|
|
106
|
+
id: assertNonEmptyString(row.id, `${rowField}.id`),
|
|
107
|
+
cells,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
ensureUnique(rows.map((row) => row.id), `${fieldName}.rows`);
|
|
111
|
+
return {
|
|
112
|
+
id,
|
|
113
|
+
type,
|
|
114
|
+
...(block.caption === undefined ? {} : { caption: assertNonEmptyString(block.caption, `${fieldName}.caption`) }),
|
|
115
|
+
headers,
|
|
116
|
+
rows,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
case 'callout':
|
|
120
|
+
return {
|
|
121
|
+
id,
|
|
122
|
+
type,
|
|
123
|
+
tone: (() => {
|
|
124
|
+
const tone = assertNonEmptyString(block.tone, `${fieldName}.tone`);
|
|
125
|
+
assert(tone === 'info' || tone === 'success' || tone === 'warning', `${fieldName}.tone must be info, success, or warning.`);
|
|
126
|
+
return tone;
|
|
127
|
+
})(),
|
|
128
|
+
...(block.title === undefined ? {} : { title: assertNonEmptyString(block.title, `${fieldName}.title`) }),
|
|
129
|
+
content: assertStringArray(block.content, `${fieldName}.content`),
|
|
130
|
+
};
|
|
131
|
+
case 'cta-group': {
|
|
132
|
+
assert(Array.isArray(block.items) && block.items.length > 0, `${fieldName}.items must be a non-empty array.`);
|
|
133
|
+
const items = block.items.map((item, index) => {
|
|
134
|
+
const itemField = `${fieldName}.items[${index}]`;
|
|
135
|
+
const normalized = assertCtaLink(item, itemField);
|
|
136
|
+
const variant = item && typeof item === 'object' ? item.variant : undefined;
|
|
137
|
+
if (variant === undefined) {
|
|
138
|
+
return normalized;
|
|
139
|
+
}
|
|
140
|
+
const variantValue = assertNonEmptyString(variant, `${itemField}.variant`);
|
|
141
|
+
assert(variantValue === 'primary' || variantValue === 'secondary', `${itemField}.variant must be primary or secondary.`);
|
|
142
|
+
const validatedVariant = variantValue;
|
|
143
|
+
return {
|
|
144
|
+
...normalized,
|
|
145
|
+
variant: validatedVariant,
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
id,
|
|
150
|
+
type,
|
|
151
|
+
items,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
default:
|
|
155
|
+
throw new Error(`${fieldName}.type ${type} is unsupported.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function validateFaq(value, fieldName) {
|
|
159
|
+
assert(Array.isArray(value) && value.length > 0, `${fieldName} must be a non-empty array.`);
|
|
160
|
+
return value.map((entry, index) => {
|
|
161
|
+
const entryField = `${fieldName}[${index}]`;
|
|
162
|
+
assert(isRecord(entry), `${entryField} must be an object.`);
|
|
163
|
+
return {
|
|
164
|
+
question: assertNonEmptyString(entry.question, `${entryField}.question`),
|
|
165
|
+
answer: assertNonEmptyString(entry.answer, `${entryField}.answer`),
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export function validateStructuredArticleDetail(detail, sourceLabel = 'structured article') {
|
|
170
|
+
assert(isRecord(detail), `${sourceLabel} must be an object.`);
|
|
171
|
+
const schemaVersion = assertNonEmptyString(detail.schemaVersion, `${sourceLabel}.schemaVersion`);
|
|
172
|
+
const slug = assertNonEmptyString(detail.slug, `${sourceLabel}.slug`);
|
|
173
|
+
const category = assertNonEmptyString(detail.category, `${sourceLabel}.category`);
|
|
174
|
+
const locale = assertNonEmptyString(detail.locale, `${sourceLabel}.locale`);
|
|
175
|
+
const updatedAt = assertNonEmptyString(detail.updatedAt, `${sourceLabel}.updatedAt`);
|
|
176
|
+
assert(isRecord(detail.seo), `${sourceLabel}.seo must be an object.`);
|
|
177
|
+
const summary = assertNonEmptyString(detail.summary, `${sourceLabel}.summary`);
|
|
178
|
+
assert(Array.isArray(detail.sections) && detail.sections.length > 0, `${sourceLabel}.sections must be a non-empty array.`);
|
|
179
|
+
assert(schemaVersion === STRUCTURED_ARTICLE_SCHEMA_VERSION, `${sourceLabel}.schemaVersion must be ${STRUCTURED_ARTICLE_SCHEMA_VERSION}.`);
|
|
180
|
+
assert(category === STRUCTURED_ARTICLE_CATEGORY, `${sourceLabel}.category must be ${STRUCTURED_ARTICLE_CATEGORY}.`);
|
|
181
|
+
const sections = detail.sections.map((section, sectionIndex) => {
|
|
182
|
+
const sectionField = `${sourceLabel}.sections[${sectionIndex}]`;
|
|
183
|
+
assert(isRecord(section), `${sectionField} must be an object.`);
|
|
184
|
+
assert(Array.isArray(section.blocks) && section.blocks.length > 0, `${sectionField}.blocks must be a non-empty array.`);
|
|
185
|
+
const blocks = section.blocks.map((block, blockIndex) => validateStructuredArticleBlock(block, `${sectionField}.blocks[${blockIndex}]`));
|
|
186
|
+
ensureUnique(blocks.map((block) => block.id), `${sectionField}.blocks`);
|
|
187
|
+
return {
|
|
188
|
+
id: assertNonEmptyString(section.id, `${sectionField}.id`),
|
|
189
|
+
title: assertNonEmptyString(section.title, `${sectionField}.title`),
|
|
190
|
+
blocks,
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
ensureUnique(sections.map((section) => section.id), `${sourceLabel}.sections`);
|
|
194
|
+
return {
|
|
195
|
+
schemaVersion,
|
|
196
|
+
slug,
|
|
197
|
+
category,
|
|
198
|
+
locale,
|
|
199
|
+
updatedAt,
|
|
200
|
+
seo: {
|
|
201
|
+
title: assertNonEmptyString(detail.seo.title, `${sourceLabel}.seo.title`),
|
|
202
|
+
description: assertNonEmptyString(detail.seo.description, `${sourceLabel}.seo.description`),
|
|
203
|
+
},
|
|
204
|
+
summary,
|
|
205
|
+
sections,
|
|
206
|
+
...(detail.faq === undefined ? {} : { faq: validateFaq(detail.faq, `${sourceLabel}.faq`) }),
|
|
207
|
+
...(detail.cta === undefined
|
|
208
|
+
? {}
|
|
209
|
+
: {
|
|
210
|
+
cta: {
|
|
211
|
+
...(isRecord(detail.cta) && detail.cta.primary !== undefined
|
|
212
|
+
? { primary: assertCtaLink(detail.cta.primary, `${sourceLabel}.cta.primary`) }
|
|
213
|
+
: {}),
|
|
214
|
+
...(isRecord(detail.cta) && detail.cta.secondary !== undefined
|
|
215
|
+
? { secondary: assertCtaLink(detail.cta.secondary, `${sourceLabel}.cta.secondary`) }
|
|
216
|
+
: {}),
|
|
217
|
+
},
|
|
218
|
+
}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function pickLatestTimestamp(values) {
|
|
222
|
+
const sorted = [...values].sort((left, right) => left.localeCompare(right));
|
|
223
|
+
return sorted.at(-1) ?? new Date(0).toISOString();
|
|
224
|
+
}
|
|
225
|
+
export function buildStructuredArticleDetailPath(locale, slug) {
|
|
226
|
+
return `/articles/${locale}/${slug}.json`;
|
|
227
|
+
}
|
|
228
|
+
export function buildStructuredArticleLocaleManifestPath(locale) {
|
|
229
|
+
return `/articles/${locale}/index.json`;
|
|
230
|
+
}
|
|
231
|
+
/** Builds one locale manifest from details that are already loaded and validated. */
|
|
232
|
+
export function buildStructuredArticleLocaleManifestFromDetails(locale, details) {
|
|
233
|
+
assert(details.length > 0, `Locale ${locale} must contain at least one structured article detail.`);
|
|
234
|
+
return {
|
|
235
|
+
schemaVersion: STRUCTURED_ARTICLE_SCHEMA_VERSION,
|
|
236
|
+
locale,
|
|
237
|
+
generatedAt: pickLatestTimestamp(details.map((detail) => detail.updatedAt)),
|
|
238
|
+
articles: details.map((detail) => ({
|
|
239
|
+
slug: detail.slug,
|
|
240
|
+
category: detail.category,
|
|
241
|
+
path: buildStructuredArticleDetailPath(locale, detail.slug),
|
|
242
|
+
updatedAt: detail.updatedAt,
|
|
243
|
+
title: detail.seo.title,
|
|
244
|
+
summary: detail.summary,
|
|
245
|
+
})),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/** Builds the root manifest from locale manifests that were built from loaded details. */
|
|
249
|
+
export function buildStructuredArticleRootManifestFromLocaleManifests(localeManifests) {
|
|
250
|
+
assert(localeManifests.length > 0, 'Structured article source must contain at least one locale directory.');
|
|
251
|
+
return {
|
|
252
|
+
schemaVersion: STRUCTURED_ARTICLE_SCHEMA_VERSION,
|
|
253
|
+
generatedAt: pickLatestTimestamp(localeManifests.map((manifest) => manifest.generatedAt)),
|
|
254
|
+
localeIndexes: localeManifests.map((manifest) => ({
|
|
255
|
+
locale: manifest.locale,
|
|
256
|
+
path: buildStructuredArticleLocaleManifestPath(manifest.locale),
|
|
257
|
+
updatedAt: manifest.generatedAt,
|
|
258
|
+
})),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export declare const CONTENT_IMAGE_CLASS = "hagilight-content-image";
|
|
2
|
+
export type ContentImageLoading = 'lazy' | 'eager';
|
|
3
|
+
export type ContentImageDecoding = 'async' | 'sync' | 'auto';
|
|
4
|
+
export interface ContentImageOptions {
|
|
5
|
+
/** Loading value for body images whose author set none. Defaults to `lazy`. */
|
|
6
|
+
loading?: ContentImageLoading;
|
|
7
|
+
/** Decoding value for body images whose author set none. Defaults to `async`. */
|
|
8
|
+
decoding?: ContentImageDecoding;
|
|
9
|
+
/** Marker class added once to every body image. Defaults to `hagilight-content-image`. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ResolvedContentImageOptions {
|
|
13
|
+
loading: ContentImageLoading;
|
|
14
|
+
decoding: ContentImageDecoding;
|
|
15
|
+
className: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ContentImageAuthorValues {
|
|
18
|
+
hasLoading: boolean;
|
|
19
|
+
hasDecoding: boolean;
|
|
20
|
+
classNames: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface ContentImagePatch {
|
|
23
|
+
loading?: ContentImageLoading;
|
|
24
|
+
decoding?: ContentImageDecoding;
|
|
25
|
+
classNames?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface MdxAttributeLike {
|
|
28
|
+
type?: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
value?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface ContentImageNode {
|
|
33
|
+
type: string;
|
|
34
|
+
tagName?: string;
|
|
35
|
+
name?: string | null;
|
|
36
|
+
properties?: Record<string, unknown>;
|
|
37
|
+
attributes?: MdxAttributeLike[];
|
|
38
|
+
children?: ContentImageNode[];
|
|
39
|
+
/** Source text of an `mdxjsEsm` node. */
|
|
40
|
+
value?: string;
|
|
41
|
+
/** ESTree data of an `mdxjsEsm` node, read by the unified MDX compiler. */
|
|
42
|
+
data?: unknown;
|
|
43
|
+
}
|
|
44
|
+
/** Per-document state for MDX picture output on the Sätteri processor. */
|
|
45
|
+
export interface MdxPictureScope {
|
|
46
|
+
/** Decoded `src` to the identifier its asset import binds. */
|
|
47
|
+
assets: Map<string, string>;
|
|
48
|
+
/** Whether the `Picture` component import has been queued for this document. */
|
|
49
|
+
component: boolean;
|
|
50
|
+
/** Import nodes not yet placed in the document. */
|
|
51
|
+
pending: ContentImageNode[];
|
|
52
|
+
}
|
|
53
|
+
export interface LocalImageData {
|
|
54
|
+
astro?: {
|
|
55
|
+
localImagePaths?: Set<string> | readonly string[];
|
|
56
|
+
};
|
|
57
|
+
/** Sätteri's per-document MDX picture state, created on first use. */
|
|
58
|
+
hagilightContentPicture?: MdxPictureScope;
|
|
59
|
+
}
|
|
60
|
+
export interface SatteriContentImageContext {
|
|
61
|
+
readonly sourceFormat: string;
|
|
62
|
+
readonly fileURL?: URL | undefined;
|
|
63
|
+
readonly data: LocalImageData;
|
|
64
|
+
parent(node: unknown): unknown;
|
|
65
|
+
setProperty(node: unknown, key: string, value: unknown): void;
|
|
66
|
+
replaceNode(node: unknown, newNode: ContentImageNode): void;
|
|
67
|
+
prependChild(node: unknown, childNode: ContentImageNode | ContentImageNode[]): void;
|
|
68
|
+
}
|
|
69
|
+
export interface SatteriContentImageVisitor {
|
|
70
|
+
filter: string[];
|
|
71
|
+
visit(node: ContentImageNode, ctx: SatteriContentImageContext): void;
|
|
72
|
+
}
|
|
73
|
+
export interface SatteriContentImagePlugin {
|
|
74
|
+
name: string;
|
|
75
|
+
element: SatteriContentImageVisitor;
|
|
76
|
+
mdxJsxFlowElement: SatteriContentImageVisitor;
|
|
77
|
+
mdxJsxTextElement: SatteriContentImageVisitor;
|
|
78
|
+
}
|
|
79
|
+
export interface PictureStep {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
/** Filesystem path of the project's `publicDir`. Images that resolve into it keep their markup. */
|
|
82
|
+
publicDir?: string;
|
|
83
|
+
}
|
|
84
|
+
export interface ContentImageRegistrationInput {
|
|
85
|
+
config: {
|
|
86
|
+
markdown?: {
|
|
87
|
+
processor?: unknown;
|
|
88
|
+
};
|
|
89
|
+
image?: {
|
|
90
|
+
service?: {
|
|
91
|
+
entrypoint?: unknown;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
publicDir?: unknown;
|
|
95
|
+
};
|
|
96
|
+
logger: {
|
|
97
|
+
warn(message: string): void;
|
|
98
|
+
};
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
}
|
|
101
|
+
export declare function resolveContentImageOptions(options?: ContentImageOptions): ResolvedContentImageOptions;
|
|
102
|
+
export declare function contentImagePatch(author: ContentImageAuthorValues, options: ResolvedContentImageOptions): ContentImagePatch;
|
|
103
|
+
export declare function hastImagePatch(properties: Record<string, unknown>, options: ResolvedContentImageOptions): ContentImagePatch;
|
|
104
|
+
export interface MdxImagePatch {
|
|
105
|
+
loading?: ContentImageLoading;
|
|
106
|
+
decoding?: ContentImageDecoding;
|
|
107
|
+
className?: string;
|
|
108
|
+
}
|
|
109
|
+
/** A class written as an expression cannot be merged statically, so its marker is left out. */
|
|
110
|
+
export declare function mdxImagePatch(attributes: readonly MdxAttributeLike[], options: ResolvedContentImageOptions): MdxImagePatch;
|
|
111
|
+
export interface UnifiedFileLike {
|
|
112
|
+
path?: unknown;
|
|
113
|
+
data?: LocalImageData;
|
|
114
|
+
}
|
|
115
|
+
/** Unified rehype plugin for sites whose `markdown.processor` is `unified()`. */
|
|
116
|
+
export declare function rehypeContentImages(options?: ContentImageOptions, picture?: PictureStep): (tree: ContentImageNode, file?: UnifiedFileLike) => void;
|
|
117
|
+
/** Sätteri hast plugin: Astro's default Markdown processor, through `hastPlugins`. */
|
|
118
|
+
export declare function satteriContentImages(options?: ContentImageOptions, picture?: PictureStep): SatteriContentImagePlugin;
|
|
119
|
+
/**
|
|
120
|
+
* Register the content-image plugin on the active Markdown processor. The first enabled
|
|
121
|
+
* call appends one adapter; an `enabled: false` call opts the whole site out and removes
|
|
122
|
+
* only the adapter it did not append, so the result does not depend on hook order.
|
|
123
|
+
*/
|
|
124
|
+
export declare function registerContentImages({ config, logger, enabled }: ContentImageRegistrationInput): void;
|
|
125
|
+
/** `astro:config:done` re-check: warns once if an enabled site's adapter is missing from the final processor. */
|
|
126
|
+
export declare function checkContentImageRegistration({ config, logger, enabled }: ContentImageRegistrationInput): void;
|