@hagicode/hagilight-docusaurus 0.11.0 → 0.11.1-dev.129.1.ea757b8
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/README.md +30 -1
- package/dist/analytics.d.ts +1 -0
- package/dist/analytics.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/options.d.ts +5 -0
- package/dist/options.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ Every option is optional. Feature toggles take an object with `enabled`, which d
|
|
|
50
50
|
| `footer` | `{ enabled: true }` | Replaces the Docusaurus footer with the Hagilight footer. Uses `links`. |
|
|
51
51
|
| `links` | `{}` | Site link configuration from `@hagicode/hagilight-core`: `overrides`, `extraLinks`, `removeLinks`, `relatedSites`, `rssFeedUrl`, `rssLocaleFeedUrl`, `siteId`, `siteUrl`. |
|
|
52
52
|
| `analytics.googleAnalytics` | built-in ID, enabled | `{ enabled, measurementId }`. Loads gtag in production builds only. |
|
|
53
|
+
| `analytics.posthog` | built-in key, enabled | `{ enabled, apiKey }`. Loads PostHog in the global head in production builds only. |
|
|
53
54
|
| `analytics.fiftyOneLa` | built-in ID, enabled | `{ enabled, siteId }`. Loads 51LA in production builds only. |
|
|
54
55
|
| `promoto` | `{ enabled: true }` | Shows the promotion banner and its styles. |
|
|
55
56
|
| `languageSelector` | `{ enabled: true }` | Controls the locale configuration warnings. It does not render a dropdown. Add `{ type: 'localeDropdown' }` to `themeConfig.navbar.items` for the switcher. |
|
|
@@ -61,10 +62,38 @@ Every option is optional. Feature toggles take an object with `enabled`, which d
|
|
|
61
62
|
|
|
62
63
|
### Analytics defaults
|
|
63
64
|
|
|
64
|
-
The built-in analytics IDs (`G-EN03FMT2Q4` and
|
|
65
|
+
The built-in analytics IDs (`G-EN03FMT2Q4`, 51LA `L6b88a5yK4h2Xnci`, and PostHog `phc_qiVVihsL925ovhPYNdLJWz4k7aoKVMwYCevgZPE6PER5`) belong to HagiCode. A site that omits `analytics` sends its traffic to HagiCode's properties. Set your own IDs, or disable each provider with `enabled: false`.
|
|
65
66
|
|
|
66
67
|
An analytics object enables its provider when it contains an ID. Set `enabled` explicitly to override that. `enabled: true` with no ID is a configuration error.
|
|
67
68
|
|
|
69
|
+
PostHog needs no configuration or consumer project key when registering `hagilightDocusaurus()`. It uses `phc_qiVVihsL925ovhPYNdLJWz4k7aoKVMwYCevgZPE6PER5`, API host `https://us.i.posthog.com`, and SDK defaults `2026-05-30`. Its single inline initialization shares the global head with Google Analytics on every production HTML page, including localized docs, blogs and not-found pages. No PostHog loader is emitted outside production.
|
|
70
|
+
|
|
71
|
+
| PostHog input | Behavior |
|
|
72
|
+
| --- | --- |
|
|
73
|
+
| Plugin options omitted, `analytics: {}`, or `posthog` omitted | Enabled with the supplied default key |
|
|
74
|
+
| `posthog: {}` | Disabled, like an empty Google Analytics provider |
|
|
75
|
+
| `posthog: { apiKey: 'phc_Custom123' }` | Enabled with the custom key |
|
|
76
|
+
| `posthog: { enabled: true, apiKey: 'phc_Custom123' }` | Enabled with the custom key |
|
|
77
|
+
| `posthog: { enabled: true }` | Configuration error: `apiKey` required |
|
|
78
|
+
| `posthog: { enabled: false }` | Disabled independently of Google Analytics and 51LA |
|
|
79
|
+
|
|
80
|
+
Keys must match `^phc_[A-Za-z0-9]+$`; enabled providers reject missing or malformed keys. Provider options must be objects and `enabled` must be boolean.
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
hagilightDocusaurus(); // shared analytics defaults
|
|
84
|
+
hagilightDocusaurus({ analytics: { posthog: { apiKey: 'phc_Custom123' } } });
|
|
85
|
+
hagilightDocusaurus({ analytics: { posthog: { enabled: false } } });
|
|
86
|
+
hagilightDocusaurus({
|
|
87
|
+
analytics: {
|
|
88
|
+
googleAnalytics: { enabled: false },
|
|
89
|
+
fiftyOneLa: { enabled: false },
|
|
90
|
+
posthog: { enabled: false },
|
|
91
|
+
},
|
|
92
|
+
}); // all analytics disabled
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Each provider is independent: disabling Google Analytics and 51LA alone leaves PostHog enabled. Choose one PostHog initialization owner and opt out here if the site already supplies it. The loader initializes once per document, and the supplied SDK defaults own navigation tracking; Hagilight adds no PostHog capture calls or route listeners. The existing analytics client module remains registered only for Google Analytics and 51LA, preserving their navigation behavior.
|
|
96
|
+
|
|
68
97
|
### SEO
|
|
69
98
|
|
|
70
99
|
- `seo.image` is an absolute HTTP(S) URL or a site-root path. When it is unset, `themeConfig.image` is the fallback sharing image.
|
package/dist/analytics.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HtmlTagObject } from '@docusaurus/types';
|
|
2
|
+
export declare function posthogHeadTags(apiKey: string): HtmlTagObject[];
|
|
2
3
|
export declare const DEFAULT_GOOGLE_ANALYTICS_ID = "G-EN03FMT2Q4";
|
|
3
4
|
export declare const DEFAULT_FIFTY_ONE_LA_ID = "L6b88a5yK4h2Xnci";
|
|
4
5
|
export declare const GOOGLE_ANALYTICS_ID_PATTERN: RegExp;
|
package/dist/analytics.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { posthogInitScript } from '@hagicode/hagilight-core/posthog';
|
|
2
|
+
export function posthogHeadTags(apiKey) {
|
|
3
|
+
return [{ tagName: 'script', innerHTML: posthogInitScript(apiKey) }];
|
|
4
|
+
}
|
|
1
5
|
export const DEFAULT_GOOGLE_ANALYTICS_ID = 'G-EN03FMT2Q4';
|
|
2
6
|
export const DEFAULT_FIFTY_ONE_LA_ID = 'L6b88a5yK4h2Xnci';
|
|
3
7
|
export const GOOGLE_ANALYTICS_ID_PATTERN = /^G-[A-Z0-9]+$/u;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { PLUGIN_NAME, type HagilightGlobalData } from './global-data.js';
|
|
|
3
3
|
import { type HagilightDocusaurusOptions } from './options.js';
|
|
4
4
|
export { PLUGIN_NAME };
|
|
5
5
|
export type { HagilightGlobalData };
|
|
6
|
-
export type { AnalyticsOptions, FeatureToggle, FiftyOneLaOptions, GoogleAnalyticsOptions, HagilightDocusaurusOptions, ResolvedHagilightOptions, RssOptions, SeoOptions, SeoOrganizationOptions, } from './options.js';
|
|
6
|
+
export type { AnalyticsOptions, FeatureToggle, FiftyOneLaOptions, GoogleAnalyticsOptions, PostHogOptions, HagilightDocusaurusOptions, ResolvedHagilightOptions, RssOptions, SeoOptions, SeoOrganizationOptions, } from './options.js';
|
|
7
7
|
export declare function hagilightDocusaurus(options?: HagilightDocusaurusOptions): PluginModule;
|
|
8
8
|
export default hagilightDocusaurus;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { resolveBuildInfo } from '@hagicode/hagilight-core/build-info-resolver';
|
|
4
|
-
import { fiftyOneLaHeadTags, googleAnalyticsHeadTags } from './analytics.js';
|
|
4
|
+
import { fiftyOneLaHeadTags, googleAnalyticsHeadTags, posthogHeadTags } from './analytics.js';
|
|
5
5
|
import { collectFeedItems, feedHeadTags, writeDiscoveryOutputs } from './discovery.js';
|
|
6
6
|
import { PLUGIN_NAME } from './global-data.js';
|
|
7
7
|
import { resolveOptions } from './options.js';
|
|
@@ -18,6 +18,7 @@ function analyticsHeadTags(options) {
|
|
|
18
18
|
return [
|
|
19
19
|
...(options.googleAnalyticsId === undefined ? [] : googleAnalyticsHeadTags(options.googleAnalyticsId)),
|
|
20
20
|
...(options.fiftyOneLaId === undefined ? [] : fiftyOneLaHeadTags(options.fiftyOneLaId)),
|
|
21
|
+
...(options.posthogApiKey === undefined ? [] : posthogHeadTags(options.posthogApiKey)),
|
|
21
22
|
];
|
|
22
23
|
}
|
|
23
24
|
/** Exposes the footer site identifier to the client banner, which tags its call to action with it. */
|
package/dist/options.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface FiftyOneLaOptions extends FeatureToggle {
|
|
|
11
11
|
export interface AnalyticsOptions {
|
|
12
12
|
googleAnalytics?: GoogleAnalyticsOptions;
|
|
13
13
|
fiftyOneLa?: FiftyOneLaOptions;
|
|
14
|
+
posthog?: PostHogOptions;
|
|
15
|
+
}
|
|
16
|
+
export interface PostHogOptions extends FeatureToggle {
|
|
17
|
+
apiKey?: string;
|
|
14
18
|
}
|
|
15
19
|
export interface SeoOrganizationOptions {
|
|
16
20
|
name?: string;
|
|
@@ -52,6 +56,7 @@ export interface ResolvedHagilightOptions {
|
|
|
52
56
|
links: SiteLinksOptions;
|
|
53
57
|
googleAnalyticsId: string | undefined;
|
|
54
58
|
fiftyOneLaId: string | undefined;
|
|
59
|
+
posthogApiKey: string | undefined;
|
|
55
60
|
promoto: boolean;
|
|
56
61
|
languageSelector: boolean;
|
|
57
62
|
seo: ResolvedSeoOptions;
|
package/dist/options.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_POSTHOG_API_KEY, POSTHOG_API_KEY_PATTERN } from '@hagicode/hagilight-core/posthog';
|
|
1
2
|
import { isValidSeoImageReference, resolveAbsoluteHttpUrl } from '@hagicode/hagilight-core/seo';
|
|
2
3
|
import { DEFAULT_FIFTY_ONE_LA_ID, DEFAULT_GOOGLE_ANALYTICS_ID, FIFTY_ONE_LA_ID_PATTERN, GOOGLE_ANALYTICS_ID_PATTERN, } from './analytics.js';
|
|
3
4
|
function invalid(path, reason) {
|
|
@@ -90,6 +91,7 @@ export function resolveOptions(input) {
|
|
|
90
91
|
links: options.links === undefined ? {} : objectOption(options.links, 'links'),
|
|
91
92
|
googleAnalyticsId: resolveProvider(analytics.googleAnalytics, 'analytics.googleAnalytics', 'measurementId', GOOGLE_ANALYTICS_ID_PATTERN, DEFAULT_GOOGLE_ANALYTICS_ID),
|
|
92
93
|
fiftyOneLaId: resolveProvider(analytics.fiftyOneLa, 'analytics.fiftyOneLa', 'siteId', FIFTY_ONE_LA_ID_PATTERN, DEFAULT_FIFTY_ONE_LA_ID),
|
|
94
|
+
posthogApiKey: resolveProvider(analytics.posthog, 'analytics.posthog', 'apiKey', POSTHOG_API_KEY_PATTERN, DEFAULT_POSTHOG_API_KEY),
|
|
93
95
|
promoto: featureEnabled(options.promoto, 'promoto'),
|
|
94
96
|
languageSelector: featureEnabled(options.languageSelector, 'languageSelector'),
|
|
95
97
|
seo: resolveSeo(options.seo),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/hagilight-docusaurus",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1-dev.129.1.ea757b8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Docusaurus plugin for HagiCode site features: footer, analytics, promote card, locales, SEO, sitemap, robots.txt, and RSS",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@docusaurus/types": "^3.9.2",
|
|
41
|
-
"@hagicode/hagilight-core": "0.11.
|
|
41
|
+
"@hagicode/hagilight-core": "0.11.1-dev.129.1.ea757b8"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@docusaurus/core": "^3.9.2",
|