@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.
Files changed (205) hide show
  1. package/Analytics51LA.astro +17 -0
  2. package/Copyright.astro +9 -0
  3. package/Footer.astro +208 -0
  4. package/FooterAvatarPicker.astro +9 -0
  5. package/FooterBrand.astro +339 -0
  6. package/GoogleAnalytics.astro +30 -0
  7. package/PostHog.astro +11 -0
  8. package/PromotoBanner.astro +582 -0
  9. package/README.md +485 -0
  10. package/RootTransit.astro +599 -0
  11. package/assets/footer/avatar.avif +0 -0
  12. package/assets/footer/avatar.webp +0 -0
  13. package/assets/footer/manifest.json +237 -0
  14. package/data/comparison-articles/de-DE/claude-vs-hagicode.json +294 -0
  15. package/data/comparison-articles/de-DE/codebuddy-vs-hagicode.json +266 -0
  16. package/data/comparison-articles/de-DE/codex-vs-hagicode.json +266 -0
  17. package/data/comparison-articles/de-DE/copilot-vs-hagicode.json +266 -0
  18. package/data/comparison-articles/de-DE/deepagents-vs-hagicode.json +266 -0
  19. package/data/comparison-articles/de-DE/gemini-vs-hagicode.json +266 -0
  20. package/data/comparison-articles/de-DE/hermes-vs-hagicode.json +266 -0
  21. package/data/comparison-articles/de-DE/kimi-vs-hagicode.json +266 -0
  22. package/data/comparison-articles/de-DE/kiro-vs-hagicode.json +266 -0
  23. package/data/comparison-articles/de-DE/opencode-vs-hagicode.json +266 -0
  24. package/data/comparison-articles/de-DE/pi-vs-hagicode.json +282 -0
  25. package/data/comparison-articles/de-DE/qoder-vs-hagicode.json +266 -0
  26. package/data/comparison-articles/de-DE/reasonix-vs-hagicode.json +281 -0
  27. package/data/comparison-articles/en-US/claude-vs-hagicode.json +346 -0
  28. package/data/comparison-articles/en-US/codebuddy-vs-hagicode.json +322 -0
  29. package/data/comparison-articles/en-US/codex-vs-hagicode.json +321 -0
  30. package/data/comparison-articles/en-US/copilot-vs-hagicode.json +320 -0
  31. package/data/comparison-articles/en-US/deepagents-vs-hagicode.json +323 -0
  32. package/data/comparison-articles/en-US/dsh-vs-hagicode.json +323 -0
  33. package/data/comparison-articles/en-US/gemini-vs-hagicode.json +320 -0
  34. package/data/comparison-articles/en-US/hermes-vs-hagicode.json +323 -0
  35. package/data/comparison-articles/en-US/junie-vs-hagicode.json +323 -0
  36. package/data/comparison-articles/en-US/kimi-vs-hagicode.json +319 -0
  37. package/data/comparison-articles/en-US/kiro-vs-hagicode.json +319 -0
  38. package/data/comparison-articles/en-US/omp-vs-hagicode.json +345 -0
  39. package/data/comparison-articles/en-US/opencode-vs-hagicode.json +333 -0
  40. package/data/comparison-articles/en-US/pi-vs-hagicode.json +345 -0
  41. package/data/comparison-articles/en-US/qoder-vs-hagicode.json +323 -0
  42. package/data/comparison-articles/en-US/reasonix-vs-hagicode.json +344 -0
  43. package/data/comparison-articles/es-ES/claude-vs-hagicode.json +294 -0
  44. package/data/comparison-articles/es-ES/codebuddy-vs-hagicode.json +266 -0
  45. package/data/comparison-articles/es-ES/codex-vs-hagicode.json +266 -0
  46. package/data/comparison-articles/es-ES/copilot-vs-hagicode.json +266 -0
  47. package/data/comparison-articles/es-ES/deepagents-vs-hagicode.json +266 -0
  48. package/data/comparison-articles/es-ES/gemini-vs-hagicode.json +266 -0
  49. package/data/comparison-articles/es-ES/hermes-vs-hagicode.json +266 -0
  50. package/data/comparison-articles/es-ES/kimi-vs-hagicode.json +266 -0
  51. package/data/comparison-articles/es-ES/kiro-vs-hagicode.json +266 -0
  52. package/data/comparison-articles/es-ES/opencode-vs-hagicode.json +266 -0
  53. package/data/comparison-articles/es-ES/pi-vs-hagicode.json +281 -0
  54. package/data/comparison-articles/es-ES/qoder-vs-hagicode.json +266 -0
  55. package/data/comparison-articles/es-ES/reasonix-vs-hagicode.json +281 -0
  56. package/data/comparison-articles/fr-FR/claude-vs-hagicode.json +294 -0
  57. package/data/comparison-articles/fr-FR/codebuddy-vs-hagicode.json +266 -0
  58. package/data/comparison-articles/fr-FR/codex-vs-hagicode.json +266 -0
  59. package/data/comparison-articles/fr-FR/copilot-vs-hagicode.json +266 -0
  60. package/data/comparison-articles/fr-FR/deepagents-vs-hagicode.json +266 -0
  61. package/data/comparison-articles/fr-FR/gemini-vs-hagicode.json +266 -0
  62. package/data/comparison-articles/fr-FR/hermes-vs-hagicode.json +266 -0
  63. package/data/comparison-articles/fr-FR/kimi-vs-hagicode.json +266 -0
  64. package/data/comparison-articles/fr-FR/kiro-vs-hagicode.json +266 -0
  65. package/data/comparison-articles/fr-FR/opencode-vs-hagicode.json +266 -0
  66. package/data/comparison-articles/fr-FR/pi-vs-hagicode.json +281 -0
  67. package/data/comparison-articles/fr-FR/qoder-vs-hagicode.json +266 -0
  68. package/data/comparison-articles/fr-FR/reasonix-vs-hagicode.json +281 -0
  69. package/data/comparison-articles/ja-JP/claude-vs-hagicode.json +294 -0
  70. package/data/comparison-articles/ja-JP/codebuddy-vs-hagicode.json +266 -0
  71. package/data/comparison-articles/ja-JP/codex-vs-hagicode.json +266 -0
  72. package/data/comparison-articles/ja-JP/copilot-vs-hagicode.json +266 -0
  73. package/data/comparison-articles/ja-JP/deepagents-vs-hagicode.json +266 -0
  74. package/data/comparison-articles/ja-JP/gemini-vs-hagicode.json +266 -0
  75. package/data/comparison-articles/ja-JP/hermes-vs-hagicode.json +266 -0
  76. package/data/comparison-articles/ja-JP/kimi-vs-hagicode.json +266 -0
  77. package/data/comparison-articles/ja-JP/kiro-vs-hagicode.json +266 -0
  78. package/data/comparison-articles/ja-JP/opencode-vs-hagicode.json +266 -0
  79. package/data/comparison-articles/ja-JP/pi-vs-hagicode.json +281 -0
  80. package/data/comparison-articles/ja-JP/qoder-vs-hagicode.json +266 -0
  81. package/data/comparison-articles/ja-JP/reasonix-vs-hagicode.json +281 -0
  82. package/data/comparison-articles/ko-KR/claude-vs-hagicode.json +294 -0
  83. package/data/comparison-articles/ko-KR/codebuddy-vs-hagicode.json +266 -0
  84. package/data/comparison-articles/ko-KR/codex-vs-hagicode.json +266 -0
  85. package/data/comparison-articles/ko-KR/copilot-vs-hagicode.json +266 -0
  86. package/data/comparison-articles/ko-KR/deepagents-vs-hagicode.json +266 -0
  87. package/data/comparison-articles/ko-KR/gemini-vs-hagicode.json +266 -0
  88. package/data/comparison-articles/ko-KR/hermes-vs-hagicode.json +266 -0
  89. package/data/comparison-articles/ko-KR/kimi-vs-hagicode.json +266 -0
  90. package/data/comparison-articles/ko-KR/kiro-vs-hagicode.json +266 -0
  91. package/data/comparison-articles/ko-KR/opencode-vs-hagicode.json +266 -0
  92. package/data/comparison-articles/ko-KR/pi-vs-hagicode.json +281 -0
  93. package/data/comparison-articles/ko-KR/qoder-vs-hagicode.json +266 -0
  94. package/data/comparison-articles/ko-KR/reasonix-vs-hagicode.json +281 -0
  95. package/data/comparison-articles/pt-BR/claude-vs-hagicode.json +294 -0
  96. package/data/comparison-articles/pt-BR/codebuddy-vs-hagicode.json +266 -0
  97. package/data/comparison-articles/pt-BR/codex-vs-hagicode.json +266 -0
  98. package/data/comparison-articles/pt-BR/copilot-vs-hagicode.json +266 -0
  99. package/data/comparison-articles/pt-BR/deepagents-vs-hagicode.json +266 -0
  100. package/data/comparison-articles/pt-BR/gemini-vs-hagicode.json +266 -0
  101. package/data/comparison-articles/pt-BR/hermes-vs-hagicode.json +266 -0
  102. package/data/comparison-articles/pt-BR/kimi-vs-hagicode.json +266 -0
  103. package/data/comparison-articles/pt-BR/kiro-vs-hagicode.json +266 -0
  104. package/data/comparison-articles/pt-BR/opencode-vs-hagicode.json +266 -0
  105. package/data/comparison-articles/pt-BR/pi-vs-hagicode.json +281 -0
  106. package/data/comparison-articles/pt-BR/qoder-vs-hagicode.json +266 -0
  107. package/data/comparison-articles/pt-BR/reasonix-vs-hagicode.json +281 -0
  108. package/data/comparison-articles/ru-RU/claude-vs-hagicode.json +294 -0
  109. package/data/comparison-articles/ru-RU/codebuddy-vs-hagicode.json +266 -0
  110. package/data/comparison-articles/ru-RU/codex-vs-hagicode.json +266 -0
  111. package/data/comparison-articles/ru-RU/copilot-vs-hagicode.json +266 -0
  112. package/data/comparison-articles/ru-RU/deepagents-vs-hagicode.json +266 -0
  113. package/data/comparison-articles/ru-RU/gemini-vs-hagicode.json +266 -0
  114. package/data/comparison-articles/ru-RU/hermes-vs-hagicode.json +266 -0
  115. package/data/comparison-articles/ru-RU/kimi-vs-hagicode.json +266 -0
  116. package/data/comparison-articles/ru-RU/kiro-vs-hagicode.json +266 -0
  117. package/data/comparison-articles/ru-RU/opencode-vs-hagicode.json +266 -0
  118. package/data/comparison-articles/ru-RU/pi-vs-hagicode.json +281 -0
  119. package/data/comparison-articles/ru-RU/qoder-vs-hagicode.json +323 -0
  120. package/data/comparison-articles/ru-RU/reasonix-vs-hagicode.json +281 -0
  121. package/data/comparison-articles/zh-CN/claude-vs-hagicode.json +346 -0
  122. package/data/comparison-articles/zh-CN/codebuddy-vs-hagicode.json +322 -0
  123. package/data/comparison-articles/zh-CN/codex-vs-hagicode.json +321 -0
  124. package/data/comparison-articles/zh-CN/copilot-vs-hagicode.json +320 -0
  125. package/data/comparison-articles/zh-CN/deepagents-vs-hagicode.json +323 -0
  126. package/data/comparison-articles/zh-CN/dsh-vs-hagicode.json +323 -0
  127. package/data/comparison-articles/zh-CN/gemini-vs-hagicode.json +320 -0
  128. package/data/comparison-articles/zh-CN/hermes-vs-hagicode.json +323 -0
  129. package/data/comparison-articles/zh-CN/junie-vs-hagicode.json +323 -0
  130. package/data/comparison-articles/zh-CN/kimi-vs-hagicode.json +319 -0
  131. package/data/comparison-articles/zh-CN/kiro-vs-hagicode.json +319 -0
  132. package/data/comparison-articles/zh-CN/omp-vs-hagicode.json +345 -0
  133. package/data/comparison-articles/zh-CN/opencode-vs-hagicode.json +333 -0
  134. package/data/comparison-articles/zh-CN/pi-vs-hagicode.json +345 -0
  135. package/data/comparison-articles/zh-CN/qoder-vs-hagicode.json +323 -0
  136. package/data/comparison-articles/zh-CN/reasonix-vs-hagicode.json +344 -0
  137. package/data/comparison-articles/zh-Hant/claude-vs-hagicode.json +294 -0
  138. package/data/comparison-articles/zh-Hant/codebuddy-vs-hagicode.json +266 -0
  139. package/data/comparison-articles/zh-Hant/codex-vs-hagicode.json +266 -0
  140. package/data/comparison-articles/zh-Hant/copilot-vs-hagicode.json +266 -0
  141. package/data/comparison-articles/zh-Hant/deepagents-vs-hagicode.json +266 -0
  142. package/data/comparison-articles/zh-Hant/gemini-vs-hagicode.json +266 -0
  143. package/data/comparison-articles/zh-Hant/hermes-vs-hagicode.json +266 -0
  144. package/data/comparison-articles/zh-Hant/kimi-vs-hagicode.json +266 -0
  145. package/data/comparison-articles/zh-Hant/kiro-vs-hagicode.json +266 -0
  146. package/data/comparison-articles/zh-Hant/opencode-vs-hagicode.json +266 -0
  147. package/data/comparison-articles/zh-Hant/pi-vs-hagicode.json +281 -0
  148. package/data/comparison-articles/zh-Hant/qoder-vs-hagicode.json +266 -0
  149. package/data/comparison-articles/zh-Hant/reasonix-vs-hagicode.json +281 -0
  150. package/dist/analytics-events.d.ts +49 -0
  151. package/dist/analytics-events.js +113 -0
  152. package/dist/build-info-resolver.d.ts +8 -0
  153. package/dist/build-info-resolver.js +29 -0
  154. package/dist/build-info.d.ts +19 -0
  155. package/dist/build-info.js +60 -0
  156. package/dist/comparison-articles-source.d.ts +13 -0
  157. package/dist/comparison-articles-source.js +58 -0
  158. package/dist/comparison-articles.d.ts +127 -0
  159. package/dist/comparison-articles.js +260 -0
  160. package/dist/content-images.d.ts +126 -0
  161. package/dist/content-images.js +490 -0
  162. package/dist/favicon.d.ts +21 -0
  163. package/dist/favicon.js +27 -0
  164. package/dist/footer-avatar.d.ts +39 -0
  165. package/dist/footer-avatar.js +42 -0
  166. package/dist/footer-brand.d.ts +29 -0
  167. package/dist/footer-brand.js +86 -0
  168. package/dist/head.d.ts +7 -0
  169. package/dist/head.js +1 -0
  170. package/dist/link-policy.d.ts +33 -0
  171. package/dist/link-policy.js +93 -0
  172. package/dist/links.d.ts +70 -0
  173. package/dist/links.js +425 -0
  174. package/dist/posthog.d.ts +6 -0
  175. package/dist/posthog.js +17 -0
  176. package/dist/promotions.d.ts +50 -0
  177. package/dist/promotions.js +243 -0
  178. package/dist/promoto-banner.d.ts +14 -0
  179. package/dist/promoto-banner.js +499 -0
  180. package/dist/random-image.d.ts +69 -0
  181. package/dist/random-image.js +133 -0
  182. package/dist/related-sites.json +378 -0
  183. package/dist/root-transit.d.ts +12 -0
  184. package/dist/root-transit.js +221 -0
  185. package/dist/rss-footer-context.d.ts +6 -0
  186. package/dist/rss-footer-context.js +54 -0
  187. package/dist/rss-ownership.d.ts +26 -0
  188. package/dist/rss-ownership.js +63 -0
  189. package/dist/rss.d.ts +34 -0
  190. package/dist/rss.js +145 -0
  191. package/dist/seo-schema.d.ts +12 -0
  192. package/dist/seo-schema.js +20 -0
  193. package/dist/seo.d.ts +78 -0
  194. package/dist/seo.js +270 -0
  195. package/dist/site-metadata-ownership.d.ts +40 -0
  196. package/dist/site-metadata-ownership.js +72 -0
  197. package/dist/site-metadata-writer.d.ts +25 -0
  198. package/dist/site-metadata-writer.js +55 -0
  199. package/dist/site-metadata.d.ts +113 -0
  200. package/dist/site-metadata.js +256 -0
  201. package/dist/splash-images.d.ts +75 -0
  202. package/dist/splash-images.js +186 -0
  203. package/favicon.ico +0 -0
  204. package/logo.png +0 -0
  205. package/package.json +172 -0
package/README.md ADDED
@@ -0,0 +1,485 @@
1
+ # @hagicode/hagilight-core
2
+
3
+ Shared Astro components, TypeScript utilities, and brand assets for HagiCode sites. This package works with plain Astro and Starlight; it does not require Starlight.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @hagicode/hagilight-core astro
9
+ ```
10
+
11
+ Use a supported Astro version (`>=7`). The other Hagilight packages install core automatically; install it directly if your site imports core entry points.
12
+
13
+ ## Use
14
+
15
+ ```astro
16
+ ---
17
+ import Footer from '@hagicode/hagilight-core/Footer';
18
+ ---
19
+
20
+ <Footer />
21
+ ```
22
+
23
+ `Footer` renders localized site links and, when configured by a Hagilight RSS integration, feed links. Its `locale` and `links` props allow customization.
24
+
25
+ Above the links the footer states what HagiCode is: a one-line headline, the product summary, the Download and Product Docs calls to action, and the three pillars (smart, efficient, fun) in all ten locales. The calls to action are the `downloadClient` and `productDocs` quick links, so `overrides`, `removeLinks` and `siteId` apply to them and a removed link leaves no button behind; both report as `footer_brand` clicks with those ids, so the product statement can be told apart from the link lists. The block lays out by the width it is given (container queries), so it holds in a narrow Starlight content pane. As the footer scrolls into view the headline is uncovered and the pillar rules draw in, using scroll-driven animation; browsers without it, and visitors who prefer reduced motion, see the finished state. Copy comes from `@hagicode/hagilight-core/footer-brand` (`resolveFooterBrand`, `pickFooterBrandLinks`), and the Astro markup is exported as `@hagicode/hagilight-core/FooterBrand`.
26
+ The core Footer stays independent of feature packages and does not add
27
+ attribution by itself. Plain-Astro sites that want the literal
28
+ `Powered By hagilight@<version>` package attribution can replace this import with
29
+ `@hagicode/hagilight/Footer`; that component reads the exact build-time version
30
+ from `@hagicode/hagilight`'s own manifest, not from Astro.
31
+
32
+ Other entry points include `Copyright`, `PromotoBanner`, `GoogleAnalytics`, `PostHog`, and `Analytics51LA` Astro components; `links`, `favicon`, `seo`, `seo-schema`, `rss`, `rss-ownership`, `promotions`, and `analytics-events` utilities; and `logo.png` and `favicon.ico` assets. For example:
33
+
34
+ ```ts
35
+ import { resolveSiteLinks } from '@hagicode/hagilight-core/links';
36
+
37
+ const links = resolveSiteLinks('en-US');
38
+ ```
39
+
40
+ ## Footer avatar
41
+
42
+ The footer brand block shows one decorative HagiCode avatar beside the headline. `avatar` defaults to `true`; `avatar={false}` removes the element and its request. The default is `assets/footer/avatar.avif` (128 px, with `avatar.webp` as the fallback) in a 64 px box, hidden below a 360 px container. `randomAvatar` defaults to `true`: each page view swaps the default for one entry of the `hero-avatars` pool listed in `assets/footer/manifest.json`. The browser picker is `@hagicode/hagilight-core/random-image` (browser-safe, under 2 KiB minified) and it preloads with a plain `Image()`, not `fetch`, waits up to 3 seconds, and keeps the default on error or timeout. `randomAvatar={false}` ships no pool list and no picker script.
43
+
44
+ `@hagicode/hagilight-core/footer-avatar` resolves the two options (a non-boolean throws a `TypeError`) and gives the shared image attributes. The Astro footers and the Docusaurus footer render the same `<picture class="hagilight-brand__avatar">` markup.
45
+
46
+ A site with a strict `img-src` policy must allow `https://img-gen.hagicode.com` for the random swap. Without it the swap fails and the default stays.
47
+
48
+ **Pool refresh.** The pool is the `pool` object in `assets/footer/manifest.json`: `album`, `maxBytes` (40 KiB) and `entries` (`key`, `bytes`). To change it, take keys from the album's `index.json`, keep 12 to 200 unique keys each at or under `maxBytes`, audit each one as text-free, current and private-data free, and update the list. Then run `npm test`: `test/footer-imagery.test.mjs` fails on a missing file, a size or dimension mismatch, an entry over the cap, or a pool outside 12 to 200. The vendored default is `source.objectKey` in the same manifest.
49
+
50
+ ## Root transit (explicit opt-in)
51
+
52
+ Use this full-page component in an Astro root route (`src/pages/index.astro`):
53
+
54
+ ```astro
55
+ ---
56
+ import RootTransit from '@hagicode/hagilight-core/RootTransit';
57
+ ---
58
+ <RootTransit destination="/en-US/" siteName="My site" />
59
+ ```
60
+
61
+ Create the destination page first, for example `src/pages/en-US/index.astro`.
62
+ The component includes the official root transit's layout, dark/light colors,
63
+ system font stacks, outline-to-solid route sweep, beam, staggered trace and
64
+ continuation chip. It bundles its logo and favicon locally; no custom CSS,
65
+ animation setup, feature package or analytics is required. By default it also
66
+ requests one image from `img-gen.hagicode.com`; the [splash image](#splash-image)
67
+ section describes that request and how to switch it off.
68
+ The trace shows the actual configured destination, base and origin rather than
69
+ performing the official website's locale detection. Installing core alone never
70
+ changes routes. Consumers that do not import this page keep their current root.
71
+
72
+ `destination` and nonblank `siteName` are required. Optional `locale` (default
73
+ `en-US`), `heading`, `message`, and `continueLabel` supply the site's translated
74
+ copy. `links={[{ destination: '/zh-CN/', label: '简体中文', lang: 'zh-CN' }]}`
75
+ adds native alternative-language links without introducing locale selection or
76
+ storage rules. Named `head` and `footer` slots accept site-owned metadata and
77
+ quick links. Hagilight's demo is an adoption example with English at `/en-US/`
78
+ and Chinese at `/zh-CN/`; its separate Starlight demo does not opt in.
79
+
80
+ The deployment base comes from Astro's `BASE_URL`. Local `en-US/` or `/en-US/`
81
+ is relative to that base; an already based `/manual/en-US/` stays unchanged.
82
+ An absolute HTTP(S) URL must match `Astro.site` (or the request origin if absent)
83
+ and already lie within the base. Missing/blank destinations, external origins,
84
+ unsupported schemes, traversal outside the base and root aliases (including
85
+ `index.html`) throw `TypeError` prefixed `Hagilight RootTransit` during rendering
86
+ or static generation. Choose a supported content route, not the transit root.
87
+ The browser-safe `@hagicode/hagilight-core/root-transit` entry point exposes the
88
+ same destination resolver, navigation resolver, mount helper and interval.
89
+
90
+ After mounting, the page replaces the current history entry after **1,570 ms**:
91
+ the reference's 1,250 ms sweep plus 320 ms hold. Motion preferences suppress
92
+ animation without changing forwarding. The clock does not wait for animation
93
+ events, fonts or images. A normal continuation activation replaces immediately;
94
+ modified clicks retain native behavior. Leaving the document or an Astro
95
+ `astro:before-swap` event cancels the timer; `astro:page-load` mounts a newly
96
+ rendered transit page once. Back therefore does not re-enter an automatic loop.
97
+
98
+ With scripting, incoming search and fragment replace their configured counterparts
99
+ when nonempty, and the continuation anchor and timer share the resulting URL.
100
+ For example, `/manual/?utm=a#features` forwards to
101
+ `/manual/en-US/?utm=a#features`. A `?lang=` or `?next=` value is preserved as data
102
+ and never selects the destination. Without JavaScript (or if the script fails),
103
+ initial HTML still contains the heading, message and a working native link to the
104
+ configured landing page. Static HTML cannot carry a browser-only fragment or
105
+ request query into that link; automatic forwarding requires scripting.
106
+
107
+ Run `node --test test/root-transit.test.mjs` after building for URL/timer checks,
108
+ and `node test/root-transit-browser.mjs` for the minimal-consumer, responsive,
109
+ no-script, reduced-motion, base and history checks.
110
+ The latter also runs through `npm run test:viewport`. To compare a locally built
111
+ reference without changing it, set `HAGILIGHT_TRANSIT_REFERENCE_DIR` to the
112
+ official site's `dist` directory. Matching 1440/375 px captures at 625/1,250 ms
113
+ are written to `HAGILIGHT_ARTIFACT_DIR` (default `/tmp/hagilight-root-transit`),
114
+ alongside 320/375/1440 px light/dark, minimal-consumer and base-path captures.
115
+
116
+ ### Splash image
117
+
118
+ While the page forwards, `RootTransit` shows one image picked at random from the
119
+ img-gen `startup-splash` collection (`hagicode-splash-001` to `hagicode-splash-600`,
120
+ see [Image paths from img-gen](#image-paths-from-img-gen)). It is on by default. A
121
+ visit makes one request to `img-gen.hagicode.com` for an AVIF of about 20 to 50 KB,
122
+ after the page has mounted. The image is decorative, sits behind the content and takes
123
+ no layout space, so the heading, trace and links stay where they are. The splash never
124
+ delays the forward timer or a continuation click.
125
+
126
+ If the chosen image fails, one other key is tried. A second failure hides the image
127
+ with no visible message. A cache read waits at most 100 ms, and the page then
128
+ requests the network URL. The loaded image is stored in the Cache API for later
129
+ visits when the host sends CORS headers; without them the image still displays.
130
+
131
+ Pass `splash` to change it. `splash={false}` renders no splash markup and makes no request to
132
+ the image host. An object overrides any of these keys; other keys are rejected.
133
+
134
+ | Key | Default | Accepted values |
135
+ | --- | --- | --- |
136
+ | `baseUrl` | `https://img-gen.hagicode.com` | An HTTPS URL without credentials, query or fragment. A trailing slash is removed. |
137
+ | `prefix` | `startup-splash` | Letters, digits, `.`, `_` and `-` segments joined by `/`. No empty, `.` or `..` segment. |
138
+ | `count` | `600` | An integer from 1 to 9999. Keys are `hagicode-splash-001` upward. |
139
+ | `cacheName` | `hagilight.rootTransit.splash` | A non-empty string. |
140
+
141
+ The key pattern is the img-gen contract and cannot be changed. An invalid value throws a
142
+ `TypeError` prefixed `Hagilight RootTransit` during rendering.
143
+
144
+ ```astro
145
+ <RootTransit destination="/en-US/" siteName="My site" splash={false} />
146
+ <RootTransit destination="/en-US/" siteName="My site" splash={{ count: 120 }} />
147
+ ```
148
+
149
+ A site whose Content Security Policy blocks the image host should either set
150
+ `splash={false}` or allow `img-src https://img-gen.hagicode.com` and
151
+ `connect-src https://img-gen.hagicode.com`.
152
+
153
+ ## Image paths from img-gen
154
+
155
+ <!--
156
+ Checked 2026-10-20 (OpenSpec task 1.1): `https://img-gen.hagicode.com/startup-splash/manifest.json` lists 600
157
+ entries, `hagicode-splash-001` to `hagicode-splash-600`, all unique and all 1232 x 704. The manifest and an AVIF
158
+ response both send no `Access-Control-Allow-Origin` header. A Cache API write downloads with CORS, so it fails
159
+ until img-gen sends that header. `<img>` display needs no CORS and is unaffected.
160
+ -->
161
+
162
+ `@hagicode/hagilight-core/splash-images` gives other HagiCode sites the image paths of the img-gen
163
+ `startup-splash` collection. img-gen is read only here: the host serves what img-gen publishes.
164
+
165
+ | Part | Value |
166
+ | --- | --- |
167
+ | Base URL | `https://img-gen.hagicode.com` |
168
+ | Prefix | `startup-splash` |
169
+ | File name | `hagicode-splash-NNN.avif`, with NNN padded to three digits |
170
+ | Range | 1 to 600 |
171
+ | Size | 1232 x 704 AVIF |
172
+ | Authoritative list | `https://img-gen.hagicode.com/startup-splash/manifest.json` |
173
+
174
+ The manifest lists `entries[]`, each with `key`, `file`, `width`, `height` and `bytes`. A site that needs only the
175
+ images that exist should read it. A site that can tolerate a failed image may build paths from the key pattern
176
+ directly, as the relay page does. The key pattern is the img-gen contract, so `SPLASH_IMAGE_DEFAULTS` does not
177
+ change it.
178
+
179
+ Worked example: index 7 becomes key `hagicode-splash-007`, then the URL
180
+ `https://img-gen.hagicode.com/startup-splash/hagicode-splash-007.avif`.
181
+
182
+ ```js
183
+ import { pickSplashIndex, splashImageUrl } from '@hagicode/hagilight-core/splash-images';
184
+
185
+ splashImageUrl(7); // https://img-gen.hagicode.com/startup-splash/hagicode-splash-007.avif
186
+ splashImageUrl(pickSplashIndex()); // one of the 600 keys, at random
187
+ ```
188
+
189
+ Cache API example for another site. The loader reads the Cache API within 100 ms and never rejects. A miss or an
190
+ unavailable cache means the caller shows the network URL. A stored image is keyed by its full URL.
191
+
192
+ ```js
193
+ import { loadSplashImage, splashImageUrl, storeSplashImage } from '@hagicode/hagilight-core/splash-images';
194
+
195
+ const url = splashImageUrl(pickSplashIndex());
196
+ const loaded = await loadSplashImage(url);
197
+ if (loaded.source === 'cache') {
198
+ img.src = URL.createObjectURL(loaded.blob);
199
+ } else {
200
+ img.src = url;
201
+ img.addEventListener('load', () => storeSplashImage(url), { once: true });
202
+ }
203
+ ```
204
+
205
+ `storeSplashImage` downloads with a CORS `fetch` and keeps the 30 newest entries. It returns `false` when the host
206
+ sends no CORS header or the cache is unavailable, and the page still shows the image. A site with a Content
207
+ Security Policy needs `img-src https://img-gen.hagicode.com` to show the images, and `connect-src
208
+ https://img-gen.hagicode.com` for the store step.
209
+
210
+ ## Build info
211
+
212
+ `@hagicode/hagilight-core/build-info` is browser-safe. It exports the `BuildInfo` type, `normalizeBuildInfo`, `shortCommit`, and `buildInfoItems`, which turn a resolved value into the footer's Branch, Commit, and Built items. `@hagicode/hagilight-core/build-info-resolver` is Node-only: `resolveBuildInfo({ root, env, now })` reads the value for one project. Keep Node-only code out of any module that a browser bundle imports.
213
+
214
+ Each field resolves on its own, in this order:
215
+
216
+ | Field | Order | Fallback |
217
+ | --- | --- | --- |
218
+ | Branch | `HAGILIGHT_BUILD_BRANCH`, then `git symbolic-ref --short -q HEAD` | `unknown` |
219
+ | Commit | `HAGILIGHT_BUILD_COMMIT`, then `git rev-parse HEAD` | `unknown` |
220
+ | Built | `now`, in UTC, truncated to whole seconds | none; always set |
221
+
222
+ After trimming, `HAGILIGHT_BUILD_BRANCH` must be nonblank and free of control characters. `HAGILIGHT_BUILD_COMMIT` must be 7 to 64 hexadecimal characters and is stored lowercased. An invalid explicit value falls through to Git. Git runs with a 5-second timeout and its stderr is discarded. A detached HEAD, an unborn branch, a missing `git`, a directory outside any repository, or a timeout yields `unknown` for that field only. The resolver never throws.
223
+
224
+ The footer shows the commit as its first seven characters, with the full hash in the `title` attribute. The core `Footer` renders this line only when it receives a `buildInfo` prop or the `hagilight()` integration from `@hagicode/hagilight/integration` is registered; otherwise it renders no build text.
225
+
226
+ ## Site metadata file
227
+
228
+ The integrations write `.well-known/hagilight.metadata.json` into the build output. This module owns the contract, so the three packages cannot drift apart.
229
+
230
+ - `@hagicode/hagilight-core/site-metadata` is browser-safe. It exports `SITE_METADATA_PATH` (`.well-known/hagilight.metadata.json`, the only place the path is spelled), `buildSiteMetadata`, `validateSiteMetadata` (returns a list of problems; empty means valid), `serializeSiteMetadata` (minified, fixed key order, trailing newline), `detectAnalyticsLoaders` (checks built HTML for each provider's loader markers), `ANALYTICS_LOADER_MARKERS`, and `resolveSiteMetadataOption` (the shared `metadata` option resolver).
231
+ - `@hagicode/hagilight-core/site-metadata-writer` is Node-only. `findDiscoveryOutputs(outDir)` reports which discovery files the build produced, and `writeSiteMetadata({ outDir, metadata, siteOwnedFiles, logger })` writes the file through a temporary file and a rename. An existing file, in the output or in `siteOwnedFiles`, is kept and reported.
232
+ - `@hagicode/hagilight-core/site-metadata-ownership` decides which integration writes the file when plain Astro and Starlight are both registered. Starlight claims at plugin creation, plain Astro defers, and the owner's write runs after every deferring peer has reported its build step.
233
+
234
+ The file follows `schemaVersion: 1`. Fields may be added within version 1. Renaming, removing, or re-typing a field requires a new version.
235
+
236
+ ```json
237
+ {
238
+ "schemaVersion": 1,
239
+ "generator": { "name": "@hagicode/hagilight-starlight", "version": "0.1.0" },
240
+ "site": {
241
+ "name": "HagiCode Docs",
242
+ "url": "https://docs.hagicode.com/",
243
+ "base": "/",
244
+ "description": "Documentation for HagiCode."
245
+ },
246
+ "languages": {
247
+ "default": "en-US",
248
+ "locales": [
249
+ { "code": "en-US", "lang": "en-US", "path": "/" },
250
+ { "code": "zh-CN", "lang": "zh-CN", "path": "/zh-CN/" }
251
+ ]
252
+ },
253
+ "build": {
254
+ "branch": "main",
255
+ "commit": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
256
+ "builtAt": "2026-10-17T08:12:34Z"
257
+ },
258
+ "discovery": {
259
+ "sitemap": "/sitemap-index.xml",
260
+ "robots": "/robots.txt",
261
+ "rss": "/rss.xml",
262
+ "llms": "/llms.txt"
263
+ },
264
+ "analytics": { "googleAnalytics": true, "fiftyOneLa": false, "posthog": true },
265
+ "features": { "seo": true, "promoto": true }
266
+ }
267
+ ```
268
+
269
+ Rules that every writer applies:
270
+
271
+ - `site.name` comes from the `name` option, then the site's own title, then the home page name, then the URL hostname. `site.description` is omitted when no description exists.
272
+ - `build` holds the same branch, commit, and build time as the footer, with `unknown` for any value that cannot be resolved.
273
+ - `discovery` holds site-relative paths, relative to `site.base`, for the artifacts that exist in this build. A key is absent when its file is absent.
274
+ - `analytics` holds three booleans that say whether each provider's loader is in this build. Measurement IDs, 51LA site IDs, and PostHog keys are never written, and neither are environment values, absolute paths, or Git remotes.
275
+ - Only the schema fields are copied from typed inputs, so an extra input field cannot leak into the output.
276
+
277
+ ## Comparison articles
278
+
279
+ Core ships the 136 `*-vs-hagicode` comparison articles (10 locales) as JSON under `data/comparison-articles/<locale>/<slug>.json`. The files are the `1.0.0` structured-article schema, unchanged from the source they moved from. Two entry points split the API by runtime, following the build-info split:
280
+
281
+ - `@hagicode/hagilight-core/comparison-articles` is browser-safe. It exports the article types, the `STRUCTURED_ARTICLE_*` constants, `validateStructuredArticleDetail(detail, sourceLabel?)` (throws an error that names the failing field path), `buildStructuredArticleDetailPath(locale, slug)` (`/articles/<locale>/<slug>.json`), `buildStructuredArticleLocaleManifestPath(locale)`, and two manifest builders over already-loaded details: `buildStructuredArticleLocaleManifestFromDetails(locale, details)` and `buildStructuredArticleRootManifestFromLocaleManifests(localeManifests)`.
282
+ - `@hagicode/hagilight-core/comparison-articles-source` is Node-only. It exports `STRUCTURED_ARTICLE_SOURCE_ROOT`, `listStructuredArticleLocales`, `listStructuredArticleSlugs`, `loadStructuredArticleDetail`, `loadStructuredArticleLocaleDetails`, `buildStructuredArticleLocaleManifest`, and `buildStructuredArticleRootManifest`. Each function takes an optional `sourceRoot` as its last argument, which tests use. Without it, the data root resolves from the module's location, so the packaged data of the installed core version is read from any working directory.
283
+
284
+ Loading fails with an error that names the file when an article's `locale` or `slug` does not match its directory or file name.
285
+
286
+ The schema has two optional parts for real comparisons, both backward compatible with the earlier files:
287
+
288
+ - Block type `comparison-table`: `{ id, type, caption?, headers, rows }`. `headers` has at least two entries (the first labels the row-label column); each row is `{ id, cells }` with exactly one cell per header and the row label first. The consuming site renders it as an HTML `<table>`.
289
+ - Top-level `faq`: a non-empty list of `{ question, answer }`. The consuming site renders it visibly and emits the same text as `FAQPage` structured data, so keep answers self-contained.
290
+
291
+ Only `en-US` and `zh-CN` carry the rewritten comparison structure (short answer, comparison table, what the agent does well, when to choose which, co-use guide, shared HagiCode section, bottom line, FAQ). The other eight locales still hold the earlier template and get rewritten only after the English page shows search impressions for comparison queries; do not add new template articles to them. `test/comparison-article-content.test.mjs` enforces both generations.
292
+
293
+ For one article without the loaders, import the raw JSON through the pattern export:
294
+
295
+ ```ts
296
+ import claude from '@hagicode/hagilight-core/comparison-articles-data/en-US/claude-vs-hagicode.json' with { type: 'json' };
297
+ ```
298
+
299
+ Only files under `data/comparison-articles/*.json` are exported this way; every other packaged path stays private.
300
+
301
+ ## Content images
302
+
303
+ `@hagicode/hagilight-core/content-images` normalizes the `<img>` elements in Markdown and MDX body content at build time. A body image gets the marker class `hagilight-content-image`, `loading="lazy"`, and `decoding="async"`. Values the author already set are kept, existing classes are kept, and the marker is added once.
304
+
305
+ | Option | Default | Accepted values |
306
+ | --- | --- | --- |
307
+ | `loading` | `lazy` | `lazy` or `eager`, applied only when the image has no `loading` |
308
+ | `decoding` | `async` | `async`, `sync`, or `auto`, applied only when the image has no `decoding` |
309
+ | `className` | `hagilight-content-image` | A class name without whitespace |
310
+
311
+ Images inside a `<picture>` element are skipped. An MDX `class={expression}` gets no marker because its value is not known at build time. Raw HTML `<img>` tags inside a `.md` file are not normalized; use Markdown image syntax or MDX for body images.
312
+
313
+ Local body images in `.md` and `.mdx` files that Astro resolves are also wrapped in a `<picture>` element, with an AVIF `<source>` and a WebP `<source>` ahead of the `<img>`. The rule is shared by both file types. An image is wrapped only when all of these hold: it is a relative path (`./` or `../`) that Astro collects as a local file; its extension is not `.svg` or `.gif`, ignoring case, query strings, and fragments; it does not resolve into the project's `public/` directory (`publicDir`), where it keeps its plain `<img>`; the step is enabled; and it is not already inside a `<picture>` or `Picture` the author wrote. A direct import of `rehypeContentImages` or `satteriContentImages` without registration has no `publicDir`, so it skips the `public/` check and wraps every other image that passes. In `.mdx`, the plugin imports Astro's `Picture` component from `astro:assets`, and the inner `<img>` carries the marker class, `loading`, and `decoding`. Site-root, remote, and raw HTML `<img>` images are not wrapped. Astro generates the source URLs through its image service, so AVIF needs a service that can encode it. The default sharp service does. The passthrough no-op service (`astro/assets/services/noop`) does not, so the Astro integrations skip the wrapper there and log one warning. A plugin added by hand does not check the service, and its sources then point at the original bytes. Encoding adds build time, which Astro caches. In `.md`, each `<source>` also carries `src`, `loading`, `decoding`, `width`, and `height` copied from Astro's output; in `.mdx`, `<source>` carries only `srcset` and `type`. Browsers ignore the extra attributes on `source`, but they are not valid HTML there.
314
+
315
+ `hagilight()` from `@hagicode/hagilight-starlight` and `hagilight()` from `@hagicode/hagilight/integration` register the plugin automatically, for the whole site and regardless of integration order. Each one opts out through its `contentImages` option; see those packages' READMEs.
316
+
317
+ To use the plugin without a feature package, add it to the Markdown processor. With the default Sätteri processor:
318
+
319
+ ```js
320
+ import { defineConfig } from 'astro/config';
321
+ import { satteri } from '@astrojs/markdown-satteri';
322
+ import { satteriContentImages } from '@hagicode/hagilight-core/content-images';
323
+
324
+ export default defineConfig({
325
+ markdown: {
326
+ processor: satteri({ hastPlugins: [satteriContentImages()] }),
327
+ },
328
+ });
329
+ ```
330
+
331
+ With the unified processor, pass `rehypeContentImages()` in `rehypePlugins` instead, from `@astrojs/markdown-remark`'s `unified()`. Integrations that wrap Astro can call `registerContentImages({ config, logger, enabled })` in `astro:config:setup` and `checkContentImageRegistration({ config, logger, enabled })` in `astro:config:done`, both exported from the same entry point.
332
+
333
+ ## Banner placement
334
+
335
+ The banner is a fixed card at most `42rem` wide, centered between two insets: `--hagilight-promoto-inset-start` and `--hagilight-promoto-inset-end` (both default to `0px`). A layout with a sidebar or a table of contents sets them on `:root` so the card sits in the content column instead of over those rails. `@hagicode/hagilight-starlight` derives them from Starlight's own layout tokens, and `@hagicode/hagilight-docusaurus` measures the doc content column at runtime. A plain Astro site needs nothing.
336
+
337
+ ## Promotion platforms
338
+
339
+ The shared banner (`PromotoBanner`, `loadActivePromotions`) displays only promotions whose `platforms` array in Index's `/promote.json` includes `web`, in addition to being enabled, inside their activation window, and matched with `/promote_content.json`. This follows the `platforms` flag documented in the Index README. An entry whose `platforms` is missing, empty, or not an array of strings is not displayed, other values such as `hagicode` are ignored, and matching is exact (`Web` does not match). When no promotion remains, the banner shows its site fallback or stays hidden, as before.
340
+
341
+ The card rises into place when it first appears and when it returns from the Footer or the page top, and sinks away when dismissed; browsers without `@starting-style` or `linear()` get the same movement with a plain ease-out or none, and `prefers-reduced-motion` turns all of it off along with automatic rotation. With more than one promotion, a thin line along the card's bottom edge fills over eight seconds and the next promotion arrives when it completes; hovering the card, tabbing into it, or pressing pause holds the line where it is. Slide content settles in the direction of travel (Previous reverses it). The call to action, muted copy and hover colors read Starlight tokens (`--sl-color-text-accent` on `--sl-color-black`, `--sl-color-gray-2`, `--sl-color-text-high`) and fall back to values derived from the card's own text color, so themes that map only part of the ramp stay legible on dark cards. Override `--promoto-cta-bg`, `--promoto-cta-fg`, `--promoto-muted`, `--promoto-strong` or `--promoto-rotation` on `.hagilight-promoto` to retune them.
342
+
343
+ The banner stays hidden while the page is at the top during a domain's first 30 visits, and while the Footer is in view. Every page load, refresh, and page-to-page navigation counts as a visit; scrolling and hash changes do not. The per-domain counter is stored in the visitor's browser under `hagilight:promoto-banner:visit-count:<hostname>` and is never sent anywhere.
344
+
345
+ A promotion's `image` may also carry `sources`, the alternative image files that Index publishes in the order AVIF, WebP, then the original. The banner renders them as a `<picture>` in that order, with the original as its `<img>`, and skips any entry whose `type` is not an `image/*` media type or whose URL is unsafe. Each `src` is resolved against `https://index.hagicode.com` when the promotion documents load. If the browser fails to load a tier, the banner removes it and the next tier is used. A card without `sources` renders the plain `<img>` as before, and `sources` never affect the dismissal signature, so a dismissed banner stays dismissed when only its image chain changes.
346
+
347
+ ## First-party links and campaign tags
348
+
349
+ Shared link resolution classifies every destination from its parsed URL, never from substring matching, and chooses the relation attribute by that class.
350
+
351
+ | Class | Destinations | `rel` on a new-tab link |
352
+ | --- | --- | --- |
353
+ | `same-origin` | Relative URLs, or the site's own origin when `siteUrl` is set | `noopener` |
354
+ | `first-party` | Host `hagicode.com` or a subdomain of it (case-insensitive); `github.com` under the `HagiCode-org` organization | `noopener` |
355
+ | `third-party` | Every other `http:`/`https:` destination, and any other protocol | `noopener noreferrer` |
356
+
357
+ Look-alikes are third-party: `hagicode.com.evil.example`, `nothagicode.com`, `github.com/HagiCode-org-fake/site`, and `example.com/hagicode.com`. Same-tab links get no policy `rel`. The site-wide `Referrer-Policy` is unchanged, so a first-party link sends only the origin, and no site should declare `unsafe-url`.
358
+
359
+ The helpers are exported from `@hagicode/hagilight-core/links`: `classifyLink(href, { origin? })`, `getLinkRel(class)`, and `withCampaignUtm(href, { siteId, medium, origin? })`. `SiteLink.rel` is typed `'noopener' | 'noopener noreferrer'`.
360
+
361
+ ### Campaign tags
362
+
363
+ Set `siteId` to the identifier of the hosting site, and first-party `hagicode.com` destinations in the footer get campaign parameters:
364
+
365
+ ```js
366
+ resolveSiteLinks('en-US', { siteId: 'docs' });
367
+ // quick → downloadClient: https://www.hagicode.com/en-US/desktop/?utm_source=docs&utm_medium=footer
368
+ ```
369
+
370
+ - Footer `quick`, `community` and related-site entries are tagged with `utm_medium=footer`. The banner call to action is tagged with `utm_medium=promoto`. Header and filing links are not tagged.
371
+ - Only `https:` destinations on `hagicode.com` hosts are tagged. GitHub, `mailto:`, `tel:`, third-party, same-origin and relative destinations are left unchanged, and so is every destination when `siteId` is absent or blank.
372
+ - Existing `utm_source` or `utm_medium` values win. Other query parameters and the fragment are kept.
373
+ - Tags are added after deduplication, so a tagged and a clean destination still collapse into one entry. `normalizeUrl` is unchanged. Canonical URLs, `og:url` and sitemap entries are built from page URLs and never contain `utm_*`.
374
+ - Footer clicks report the tagged `href` as `link_url` in the GA click event. The `link_url` dimension therefore includes `utm_source` and `utm_medium` for first-party footer clicks. No new event parameter is added.
375
+
376
+ ### Options
377
+
378
+ - `links.siteId` (Starlight, Docusaurus, and the `Footer`/`Header` components) enables footer tags. The Starlight and Docusaurus promotion banners read this same value.
379
+ - `links.siteUrl` names the hosting site's URL for same-origin classification and for excluding its own Ecosystem Sites entry. When it is not set, the core `Footer` uses the page's Astro `site` (`Astro.site`) instead, so a site built for `https://fullstack.hagicode.com` does not list the HagiCode Fullstack entry on its own footer. An explicit `siteUrl` wins, and with neither value the footer behaves as before. The fallback never sets `siteId`, so no campaign tags are added.
380
+ - `PromotoBanner` accepts an optional `siteId` prop, written to `data-site-id`. Without it the banner keeps the class-based `rel` and leaves destinations unchanged.
381
+ - Each slide is classified and tagged on its own when it renders, so a rotation from a third-party campaign to a first-party one gets the first-party `rel` and tags.
382
+
383
+ ### Google Analytics cross-domain linker
384
+
385
+ Decision, recorded 2026-10-15 under the `first-party-link-policy-and-attribution` change: **no linker domain list is configured.**
386
+
387
+ - Every first-party host that runs HagiCode's shared `gtag` is a subdomain of `hagicode.com` (`www`, `docs`, `cost`, `design`, `index`, `soul`, `omniroute`, `openspec`, `impeccable`, `builder`, `newbe`, `awesome`, `tasks`, `trait`, `status`, `api`, and the download hosts `dl-server`, `server.dl`, `desktop.dl`, `dl-desktop`). They share the measurement ID `G-EN03FMT2Q4`, and GA4 sets its cookie on the registrable domain `hagicode.com`, so `_ga` and the session already follow a visitor between these subdomains. A linker would add nothing for them.
388
+ - One first-party destination sits on another registrable domain: `github.com/HagiCode-org/*`. It runs no HagiCode `gtag` and cannot read a `_gl` parameter, so a linker would only append `_gl` to GitHub links and make them longer. No linker is needed for it.
389
+ - Other hosts that appear in the sites, such as `hagicode-org.github.io` and Azure blob storage, are third-party under this policy and are outside the decision.
390
+ - Constraints that any future linker must respect: one `gtag('config', id)` call per page, so a `linker` setting is added to that single call in `GoogleAnalytics.astro`; the sites with their own inline `gtag` copies would each need the same change; and `_gl` must never reach canonical or sitemap URLs.
391
+ - Revisit this decision when a HagiCode-owned site runs the shared `gtag` on a registrable domain other than `hagicode.com`, or when a first-party destination on another domain also runs HagiCode's `gtag` and needs session continuity. Then list the host, add it to the linker in the single `config` call, and update the GA reference document, which lives in the monorepo root and needs its owner's follow-up edit.
392
+
393
+ ## PostHog
394
+
395
+ Render the component once in the global layout's `<head>`, alongside Google Analytics when configured:
396
+
397
+ ```astro
398
+ ---
399
+ import PostHog from '@hagicode/hagilight-core/PostHog';
400
+ import GoogleAnalytics from '@hagicode/hagilight-core/GoogleAnalytics';
401
+ ---
402
+ <html>
403
+ <head>
404
+ <PostHog />
405
+ <GoogleAnalytics measurementId="G-EN03FMT2Q4" />
406
+ </head>
407
+ <body><slot /></body>
408
+ </html>
409
+ ```
410
+
411
+ `<PostHog />` needs no enabled flag or project key. It uses `phc_qiVVihsL925ovhPYNdLJWz4k7aoKVMwYCevgZPE6PER5`, API host `https://us.i.posthog.com`, and SDK defaults `2026-05-30`. It emits no loader or initialization outside production. The SDK is loaded asynchronously with anonymous cross-origin mode from `https://us-assets.i.posthog.com/static/array.js`.
412
+
413
+ For a different project, pass `<PostHog apiKey="phc_Custom123" />`. Keys must match `^phc_[A-Za-z0-9]+$`; invalid values fail rendering before a script is emitted. The host and defaults version stay fixed.
414
+
415
+ Non-Astro integrations can import the browser-safe ESM generator and its declarations without installing Astro:
416
+
417
+ ```ts
418
+ import {
419
+ posthogInitScript,
420
+ DEFAULT_POSTHOG_API_KEY,
421
+ POSTHOG_API_HOST,
422
+ POSTHOG_DEFAULTS,
423
+ POSTHOG_API_KEY_PATTERN,
424
+ } from '@hagicode/hagilight-core/posthog';
425
+
426
+ const script = posthogInitScript(); // optional custom key as the only argument
427
+ ```
428
+
429
+ Initialization runs once per document, including when the script is re-executed before or after the SDK loads. Fresh documents initialize independently. SDK defaults own navigation tracking; Hagilight adds no PostHog capture calls or route listeners. Choose one initialization owner: omit this component when another integration initializes PostHog, or disable the plugin provider when composing it yourself. The plain Astro integration does not inject analytics automatically; the demo composes this component in its shared head (and in its transit page's head slot).
430
+
431
+ ## Google Analytics click events
432
+
433
+ `GoogleAnalytics` also reports clicks on the key links and download buttons that the shared components render. There is nothing to configure: events follow the same rules as page views, so they are sent only on production pages where Google Analytics is enabled, never on the Starlight 404 page, and silently skipped when `gtag` is missing (development builds, blocked scripts).
434
+
435
+ A click on a tagged link calls `gtag('event', <action>, …)` once:
436
+
437
+ | Field | Value |
438
+ | --- | --- |
439
+ | Event name (action) | `download_click` for the `download` category, `store_visit` for the `store` category, `link_click` for every other category |
440
+ | `event_category` | `download`, `store`, `navigation`, `community`, or `promotion` |
441
+ | `event_label` | The link's stable id (for example `downloadClient`), never its localized text |
442
+ | `link_location` | Where the link sits: `header`, `footer`, `footer_brand`, `article_promotion`, `promoto_banner`, or your own value |
443
+ | `link_url` | The destination at click time |
444
+ | `transport_type` | `beacon`, so same-tab navigations still deliver |
445
+
446
+ Reporting never delays, cancels, or changes navigation, and carries no link text, form values, or visitor identifiers.
447
+
448
+ ### Tracked links
449
+
450
+ The shared components tag exactly these links. The authoritative list is `TRACKED_SITE_LINKS` in `src/analytics-events.ts`; renaming a link id changes its GA label.
451
+
452
+ Use `store` for links to a store listing page (Microsoft Store, Steam), which reports `store_visit`. Use `download` for installers and download-hub entry points, which report `download_click`. A single click reports under one category only.
453
+
454
+ | `event_label` | `event_category` | Reported from |
455
+ | --- | --- | --- |
456
+ | `home`, `blog`, `support` | `navigation` | header (`home` also in the HagiCode showcase) |
457
+ | `dockerCompose`, `blogPosts` | `navigation` | footer quick links |
458
+ | `productDocs` | `navigation` | footer quick links, HagiCode showcase |
459
+ | `downloadClient` | `download` | footer quick links, HagiCode showcase (all-downloads link) |
460
+ | `microsoftStore` | `store` | footer quick links, HagiCode showcase (the Microsoft Store badge and its fallback link report `microsoftStore`) |
461
+ | `github`, `discord`, `issueFeedback` | `community` | footer community links |
462
+ | the promotion's id | `promotion` | floating promotion banner call to action, including rotated slides |
463
+
464
+ Related-site links, RSS, sitemap, about, contact, filings, the language chooser, and links you add through `extraLinks` do not report events. A consumer that overrides a tracked link's destination keeps the original label and reports the new destination as `link_url`.
465
+
466
+ ### Tag your own links
467
+
468
+ ```astro
469
+ ---
470
+ import { gaEventAttributes } from '@hagicode/hagilight-core/analytics-events';
471
+ ---
472
+
473
+ <a
474
+ href="/downloads/"
475
+ {...gaEventAttributes({ category: 'download', label: 'pricingDownload', location: 'pricing' })}
476
+ >Download</a>
477
+ ```
478
+
479
+ `gaEventAttributes()` returns the `data-ga-category`, `data-ga-label`, `data-ga-location`, and optional `data-ga-url` attributes (pass `url` when the tagged element has no `href` of its own). It throws a `TypeError` for an unknown category or an empty label or location. The category must be one of `download`, `store`, `navigation`, `community`, or `promotion`; action names such as `store_visit` are not categories. For a store listing, use `category: 'store'`, for example `gaEventAttributes({ category: 'store', label: 'openSteamStore', location: 'pricing' })`. A hand-written `data-ga-*` tag with an invalid category is ignored at click time. The page must render `GoogleAnalytics` for the click to be reported. `siteLinkGaAttributes(link, location)` tags a resolved site link and returns `{}` for ids outside the tracked list.
480
+
481
+ ### Reports
482
+
483
+ `event_category`, `event_label`, `link_location`, and `link_url` are custom event parameters. The property owner must register them as GA4 custom dimensions before they appear in standard reports; until then they are visible in DebugView and exports only. Ad blockers and browsers that block Google Analytics drop these events like any other, so treat the counts as directional.
484
+
485
+ See the [repository documentation](https://github.com/HagiCode-org/hagilight#readme) for the full list of entry points and usage.