@hagicode/hagilight-core 0.18.0 → 0.19.1-dev.184.1.830a4c6
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 +19 -3
- package/CookieConsent.astro +402 -0
- package/Footer.astro +31 -5
- package/FooterBrand.astro +23 -3
- package/GoogleAnalytics.astro +17 -2
- package/PostHog.astro +55 -3
- package/PromotoBanner.astro +3 -3
- package/README.md +102 -8
- package/dist/analytics-events.d.ts +15 -0
- package/dist/analytics-events.js +25 -15
- package/dist/consent-copy/de-DE.d.ts +2 -0
- package/dist/consent-copy/de-DE.js +21 -0
- package/dist/consent-copy/en-US.d.ts +2 -0
- package/dist/consent-copy/en-US.js +21 -0
- package/dist/consent-copy/es-ES.d.ts +2 -0
- package/dist/consent-copy/es-ES.js +21 -0
- package/dist/consent-copy/fr-FR.d.ts +2 -0
- package/dist/consent-copy/fr-FR.js +21 -0
- package/dist/consent-copy/index.d.ts +7 -0
- package/dist/consent-copy/index.js +31 -0
- package/dist/consent-copy/ja-JP.d.ts +2 -0
- package/dist/consent-copy/ja-JP.js +21 -0
- package/dist/consent-copy/ko-KR.d.ts +2 -0
- package/dist/consent-copy/ko-KR.js +21 -0
- package/dist/consent-copy/pt-BR.d.ts +2 -0
- package/dist/consent-copy/pt-BR.js +21 -0
- package/dist/consent-copy/ru-RU.d.ts +2 -0
- package/dist/consent-copy/ru-RU.js +21 -0
- package/dist/consent-copy/types.d.ts +22 -0
- package/dist/consent-copy/types.js +1 -0
- package/dist/consent-copy/zh-CN.d.ts +2 -0
- package/dist/consent-copy/zh-CN.js +21 -0
- package/dist/consent-copy/zh-Hant.d.ts +2 -0
- package/dist/consent-copy/zh-Hant.js +21 -0
- package/dist/consent-details.d.ts +29 -0
- package/dist/consent-details.js +41 -0
- package/dist/consent-gate.d.ts +47 -0
- package/dist/consent-gate.js +243 -0
- package/dist/consent-markup.d.ts +33 -0
- package/dist/consent-markup.js +113 -0
- package/dist/consent-mount.d.ts +26 -0
- package/dist/consent-mount.js +81 -0
- package/dist/consent-popup.d.ts +6 -0
- package/dist/consent-popup.js +203 -0
- package/dist/consent.d.ts +65 -0
- package/dist/consent.js +314 -0
- package/dist/entity-definition.d.ts +19 -0
- package/dist/entity-definition.js +23 -0
- package/dist/link-policy.d.ts +7 -2
- package/dist/link-policy.js +8 -1
- package/dist/links.d.ts +12 -4
- package/dist/links.js +16 -10
- package/dist/posthog-events.d.ts +95 -0
- package/dist/posthog-events.js +263 -0
- package/dist/posthog-interactions.d.ts +85 -0
- package/dist/posthog-interactions.js +280 -0
- package/dist/posthog.d.ts +25 -3
- package/dist/posthog.js +64 -6
- package/dist/promoto-analytics.d.ts +45 -0
- package/dist/promoto-analytics.js +92 -0
- package/dist/promoto-banner.js +62 -4
- package/dist/related-sites.json +2 -2
- package/dist/root-transit.d.ts +7 -1
- package/dist/root-transit.js +42 -1
- package/dist/seo.d.ts +30 -1
- package/dist/seo.js +93 -1
- package/dist/site-metadata.d.ts +11 -6
- package/dist/site-metadata.js +21 -8
- package/package.json +42 -1
package/dist/related-sites.json
CHANGED
|
@@ -143,8 +143,8 @@
|
|
|
143
143
|
"ru-RU": "Docker Compose Builder"
|
|
144
144
|
},
|
|
145
145
|
"description": {
|
|
146
|
-
"zh-CN": "Docker 部署
|
|
147
|
-
"zh-Hant": "使用 Docker 部署
|
|
146
|
+
"zh-CN": "Docker 部署 HagiCode",
|
|
147
|
+
"zh-Hant": "使用 Docker 部署 HagiCode",
|
|
148
148
|
"en-US": "Deploy HagiCode with Docker.",
|
|
149
149
|
"ja-JP": "Docker で HagiCode をデプロイします。",
|
|
150
150
|
"ko-KR": "Docker로 HagiCode를 배포합니다.",
|
package/dist/root-transit.d.ts
CHANGED
|
@@ -11,5 +11,11 @@ export interface TransitDestinationOptions {
|
|
|
11
11
|
export declare function resolveTransitDestination(destination: string, { site, base }: TransitDestinationOptions): string;
|
|
12
12
|
/** Browser-only search/fragment replace configured values when present. */
|
|
13
13
|
export declare function resolveTransitNavigation(destination: string, current: URL, base?: string): string;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Reports the automatic locale-driven forward as `locale_redirected`. It names the destination only when its first
|
|
16
|
+
* path segment after `base` is a known site locale, and the reason is the source the existing resolver reports.
|
|
17
|
+
* Called only from the timer-driven forward, never from a click. Never throws, and sends nothing when PostHog
|
|
18
|
+
* cannot capture.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reportLocaleRedirect(win: Window, destination: string, base?: string): void;
|
|
15
21
|
export declare function mountRootTransit(win?: Window): () => void;
|
package/dist/root-transit.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SPLASH_IMAGE_DEFAULTS, loadSplashImage, pickSplashIndex, splashImageUrl, storeSplashImage, } from './splash-images.js';
|
|
2
2
|
import { mountLocaleMonitor } from './root-transit-monitor.js';
|
|
3
|
+
import { LEGACY_SITE_LOCALE_STORAGE_KEY, SITE_LOCALE_CODES, SITE_LOCALE_STORAGE_KEY, resolveTransitLocale, } from './root-transit-locale.js';
|
|
4
|
+
import { capturePostHogEvent } from './posthog-events.js';
|
|
3
5
|
export { DEFAULT_LOCALE, LEGACY_SITE_LOCALE_STORAGE_KEY, SITE_LOCALE_STORAGE_KEY, SITE_LOCALES, normalizeTransitLocale, resolveTransitLocale, } from './root-transit-locale.js';
|
|
4
6
|
export { LOCALE_MONITOR_COOKIE, LOCALE_MONITOR_STORAGE_KEY, formatLocaleMarker, parseLocaleMarker, } from './root-transit-marker.js';
|
|
5
7
|
export { mountLocaleMonitor, resolveLocaleMonitor } from './root-transit-monitor.js';
|
|
@@ -194,6 +196,41 @@ function mountLoadingPhase(win, doc) {
|
|
|
194
196
|
return { enter, release };
|
|
195
197
|
}
|
|
196
198
|
/** Mount once per rendered root; decoration never controls the navigation clock. */
|
|
199
|
+
/** Reads a browser value, returning `undefined` when the read throws (private mode, blocked storage). */
|
|
200
|
+
function safeRead(read) {
|
|
201
|
+
try {
|
|
202
|
+
return read();
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Reports the automatic locale-driven forward as `locale_redirected`. It names the destination only when its first
|
|
210
|
+
* path segment after `base` is a known site locale, and the reason is the source the existing resolver reports.
|
|
211
|
+
* Called only from the timer-driven forward, never from a click. Never throws, and sends nothing when PostHog
|
|
212
|
+
* cannot capture.
|
|
213
|
+
*/
|
|
214
|
+
export function reportLocaleRedirect(win, destination, base = '/') {
|
|
215
|
+
try {
|
|
216
|
+
const path = new URL(destination, win.location.href).pathname;
|
|
217
|
+
const relative = base !== '/' && path.startsWith(base) ? path.slice(base.length) : path.replace(/^\//u, '');
|
|
218
|
+
const to = relative.split('/').find(Boolean);
|
|
219
|
+
if (!to || !SITE_LOCALE_CODES.includes(to))
|
|
220
|
+
return;
|
|
221
|
+
const resolution = resolveTransitLocale({
|
|
222
|
+
requestedLang: safeRead(() => new URLSearchParams(win.location.search).get('lang')),
|
|
223
|
+
storedLocale: safeRead(() => win.localStorage.getItem(SITE_LOCALE_STORAGE_KEY)),
|
|
224
|
+
legacyStoredLocale: safeRead(() => win.localStorage.getItem(LEGACY_SITE_LOCALE_STORAGE_KEY)),
|
|
225
|
+
clientLanguages: safeRead(() => [...win.navigator.languages]) ?? [],
|
|
226
|
+
});
|
|
227
|
+
const reason = resolution.source;
|
|
228
|
+
capturePostHogEvent('locale_redirected', { from: 'root', to, reason }, safeRead(() => win.posthog));
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// Analytics must never change the forward.
|
|
232
|
+
}
|
|
233
|
+
}
|
|
197
234
|
export function mountRootTransit(win = window) {
|
|
198
235
|
const doc = win.document;
|
|
199
236
|
const page = doc.querySelector('[data-root-transit]');
|
|
@@ -244,7 +281,11 @@ export function mountRootTransit(win = window) {
|
|
|
244
281
|
event.preventDefault();
|
|
245
282
|
forward(event.currentTarget.getAttribute('href') ?? target);
|
|
246
283
|
};
|
|
247
|
-
timer = win.setTimeout(() =>
|
|
284
|
+
timer = win.setTimeout(() => {
|
|
285
|
+
if (!finished)
|
|
286
|
+
reportLocaleRedirect(win, target, page.dataset.base || '/');
|
|
287
|
+
forward();
|
|
288
|
+
}, ROOT_TRANSIT_DELAY_MS);
|
|
248
289
|
mounted.set(page, cleanup);
|
|
249
290
|
for (const link of links)
|
|
250
291
|
link.addEventListener('click', continueNow);
|
package/dist/seo.d.ts
CHANGED
|
@@ -52,6 +52,24 @@ export interface OrganizationStructuredDataInput {
|
|
|
52
52
|
url: string | URL;
|
|
53
53
|
logo?: string | URL;
|
|
54
54
|
alternateName?: string;
|
|
55
|
+
sameAs?: readonly (string | URL)[];
|
|
56
|
+
}
|
|
57
|
+
export interface SoftwareApplicationOffer {
|
|
58
|
+
price: number | string;
|
|
59
|
+
priceCurrency: string;
|
|
60
|
+
url?: string | URL;
|
|
61
|
+
/** A schema.org ItemAvailability URL, or a bare term such as `InStock`. */
|
|
62
|
+
availability?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface SoftwareApplicationStructuredDataInput {
|
|
65
|
+
name: string;
|
|
66
|
+
applicationCategory: string;
|
|
67
|
+
operatingSystem: string;
|
|
68
|
+
downloadUrl?: string | URL;
|
|
69
|
+
offers?: SoftwareApplicationOffer;
|
|
70
|
+
sameAs?: readonly (string | URL)[];
|
|
71
|
+
description?: string;
|
|
72
|
+
url?: string | URL;
|
|
55
73
|
}
|
|
56
74
|
export interface WebSiteStructuredDataInput {
|
|
57
75
|
name: string;
|
|
@@ -62,6 +80,7 @@ export interface DefaultOrganizationOptions {
|
|
|
62
80
|
name?: string;
|
|
63
81
|
logo?: string | URL;
|
|
64
82
|
alternateName?: string;
|
|
83
|
+
sameAs?: readonly (string | URL)[];
|
|
65
84
|
}
|
|
66
85
|
export interface DefaultStructuredDataInput {
|
|
67
86
|
siteName?: string;
|
|
@@ -110,7 +129,17 @@ export declare function toOpenGraphLocale(tag: string | undefined): string | und
|
|
|
110
129
|
export declare function composeSocialCardHead(head: readonly HeadEntry[], card: SocialCardOptions, explicitHead?: readonly (readonly HeadEntry[] | undefined)[]): HeadEntry[];
|
|
111
130
|
export declare function buildArticleStructuredData({ url, title, description, author, publishedDate, modifiedDate, }: ArticleStructuredDataInput): StructuredData;
|
|
112
131
|
export declare function buildBreadcrumbStructuredData(items?: readonly BreadcrumbItem[]): StructuredData;
|
|
113
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Validate a list of `sameAs` URLs: each must be an absolute HTTP(S) URL, duplicates are dropped
|
|
134
|
+
* in first-seen order, and an empty input yields an empty list so the caller can omit the key.
|
|
135
|
+
*/
|
|
136
|
+
export declare function normalizeSameAs(values: readonly (string | URL)[] | undefined): string[];
|
|
137
|
+
export declare function buildOrganizationStructuredData({ name, url, logo, alternateName, sameAs, }: OrganizationStructuredDataInput): StructuredData;
|
|
138
|
+
/**
|
|
139
|
+
* Build a schema.org `SoftwareApplication` block. The required fields must be non-blank; optional
|
|
140
|
+
* values are emitted only when supplied, and nothing (price, rating, version) is invented.
|
|
141
|
+
*/
|
|
142
|
+
export declare function buildSoftwareApplicationStructuredData({ name, applicationCategory, operatingSystem, downloadUrl, offers, sameAs, description, url, }: SoftwareApplicationStructuredDataInput): StructuredData;
|
|
114
143
|
export declare function buildWebSiteStructuredData({ name, url, basePath }: WebSiteStructuredDataInput): StructuredData;
|
|
115
144
|
/**
|
|
116
145
|
* Collect the `@type` values a page already declares at the top level and inside `@graph`, from
|
package/dist/seo.js
CHANGED
|
@@ -316,7 +316,28 @@ export function buildBreadcrumbStructuredData(items = []) {
|
|
|
316
316
|
}),
|
|
317
317
|
};
|
|
318
318
|
}
|
|
319
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Validate a list of `sameAs` URLs: each must be an absolute HTTP(S) URL, duplicates are dropped
|
|
321
|
+
* in first-seen order, and an empty input yields an empty list so the caller can omit the key.
|
|
322
|
+
*/
|
|
323
|
+
export function normalizeSameAs(values) {
|
|
324
|
+
if (values === undefined)
|
|
325
|
+
return [];
|
|
326
|
+
if (!Array.isArray(values)) {
|
|
327
|
+
throw new TypeError('Hagilight SEO sameAs must be an array of absolute HTTP(S) URLs.');
|
|
328
|
+
}
|
|
329
|
+
const seen = new Set();
|
|
330
|
+
const result = [];
|
|
331
|
+
for (const value of values) {
|
|
332
|
+
const href = resolveAbsoluteHttpUrl(value, 'sameAs URL').href;
|
|
333
|
+
if (seen.has(href))
|
|
334
|
+
continue;
|
|
335
|
+
seen.add(href);
|
|
336
|
+
result.push(href);
|
|
337
|
+
}
|
|
338
|
+
return result;
|
|
339
|
+
}
|
|
340
|
+
export function buildOrganizationStructuredData({ name, url, logo, alternateName, sameAs, }) {
|
|
320
341
|
if (typeof name !== 'string' || !name.trim()) {
|
|
321
342
|
throw new TypeError('Hagilight SEO organization name must be a non-empty string.');
|
|
322
343
|
}
|
|
@@ -331,8 +352,78 @@ export function buildOrganizationStructuredData({ name, url, logo, alternateName
|
|
|
331
352
|
if (typeof alternateName === 'string' && alternateName.trim()) {
|
|
332
353
|
organization.alternateName = alternateName.trim();
|
|
333
354
|
}
|
|
355
|
+
const sameAsUrls = normalizeSameAs(sameAs);
|
|
356
|
+
if (sameAsUrls.length > 0)
|
|
357
|
+
organization.sameAs = sameAsUrls;
|
|
334
358
|
return organization;
|
|
335
359
|
}
|
|
360
|
+
function requiredText(value, field) {
|
|
361
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
362
|
+
throw new TypeError(`Hagilight SEO software ${field} must be a non-empty string.`);
|
|
363
|
+
}
|
|
364
|
+
return value.trim();
|
|
365
|
+
}
|
|
366
|
+
function optionalText(value, field) {
|
|
367
|
+
if (value === undefined)
|
|
368
|
+
return undefined;
|
|
369
|
+
return requiredText(value, field);
|
|
370
|
+
}
|
|
371
|
+
function offerAvailability(value) {
|
|
372
|
+
const trimmed = value.trim();
|
|
373
|
+
if (!trimmed)
|
|
374
|
+
throw new TypeError('Hagilight SEO software offer availability must be a non-empty string.');
|
|
375
|
+
if (/^[A-Za-z]+$/u.test(trimmed))
|
|
376
|
+
return `https://schema.org/${trimmed}`;
|
|
377
|
+
return resolveAbsoluteHttpUrl(trimmed, 'offer availability').href;
|
|
378
|
+
}
|
|
379
|
+
function buildOffer({ price, priceCurrency, url, availability }) {
|
|
380
|
+
const offer = { '@type': 'Offer' };
|
|
381
|
+
if (typeof price === 'number') {
|
|
382
|
+
if (!Number.isFinite(price) || price < 0) {
|
|
383
|
+
throw new TypeError('Hagilight SEO software offer price must be a finite, non-negative number.');
|
|
384
|
+
}
|
|
385
|
+
offer.price = price;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
offer.price = requiredText(price, 'offer price');
|
|
389
|
+
}
|
|
390
|
+
const currency = requiredText(priceCurrency, 'offer priceCurrency');
|
|
391
|
+
if (!/^[A-Z]{3}$/u.test(currency)) {
|
|
392
|
+
throw new TypeError('Hagilight SEO software offer priceCurrency must be an ISO 4217 code.');
|
|
393
|
+
}
|
|
394
|
+
offer.priceCurrency = currency;
|
|
395
|
+
if (url !== undefined)
|
|
396
|
+
offer.url = resolveAbsoluteHttpUrl(url, 'offer URL').href;
|
|
397
|
+
if (availability !== undefined)
|
|
398
|
+
offer.availability = offerAvailability(availability);
|
|
399
|
+
return offer;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Build a schema.org `SoftwareApplication` block. The required fields must be non-blank; optional
|
|
403
|
+
* values are emitted only when supplied, and nothing (price, rating, version) is invented.
|
|
404
|
+
*/
|
|
405
|
+
export function buildSoftwareApplicationStructuredData({ name, applicationCategory, operatingSystem, downloadUrl, offers, sameAs, description, url, }) {
|
|
406
|
+
const application = {
|
|
407
|
+
'@context': 'https://schema.org',
|
|
408
|
+
'@type': 'SoftwareApplication',
|
|
409
|
+
name: requiredText(name, 'name'),
|
|
410
|
+
applicationCategory: requiredText(applicationCategory, 'applicationCategory'),
|
|
411
|
+
operatingSystem: requiredText(operatingSystem, 'operatingSystem'),
|
|
412
|
+
};
|
|
413
|
+
if (downloadUrl !== undefined)
|
|
414
|
+
application.downloadUrl = resolveAbsoluteHttpUrl(downloadUrl, 'download URL').href;
|
|
415
|
+
if (offers !== undefined)
|
|
416
|
+
application.offers = buildOffer(offers);
|
|
417
|
+
const sameAsUrls = normalizeSameAs(sameAs);
|
|
418
|
+
if (sameAsUrls.length > 0)
|
|
419
|
+
application.sameAs = sameAsUrls;
|
|
420
|
+
const text = optionalText(description, 'description');
|
|
421
|
+
if (text !== undefined)
|
|
422
|
+
application.description = text;
|
|
423
|
+
if (url !== undefined)
|
|
424
|
+
application.url = resolveAbsoluteHttpUrl(url, 'application URL').href;
|
|
425
|
+
return application;
|
|
426
|
+
}
|
|
336
427
|
function siteRootHref(url, basePath = '/') {
|
|
337
428
|
return new URL(`${normalizeBasePath(basePath)}/`, resolveAbsoluteHttpUrl(url, 'site URL')).href;
|
|
338
429
|
}
|
|
@@ -403,6 +494,7 @@ export function buildDefaultStructuredData({ siteName, site, basePath, enabled =
|
|
|
403
494
|
url: siteRootHref(site, basePath),
|
|
404
495
|
logo: organization.logo,
|
|
405
496
|
alternateName: organization.alternateName,
|
|
497
|
+
sameAs: organization.sameAs,
|
|
406
498
|
}));
|
|
407
499
|
}
|
|
408
500
|
return blocks;
|
package/dist/site-metadata.d.ts
CHANGED
|
@@ -10,14 +10,17 @@ export declare const SITE_METADATA_SCHEMA_VERSION = 1;
|
|
|
10
10
|
/** Site-relative output path. This is the only place the path is spelled. */
|
|
11
11
|
export declare const SITE_METADATA_PATH = ".well-known/hagilight.metadata.json";
|
|
12
12
|
/**
|
|
13
|
-
* Substrings that a provider
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Substrings that a provider leaves in built HTML. Each provider is a list of
|
|
14
|
+
* alternatives: a page shows the provider when it carries every marker of one
|
|
15
|
+
* alternative. The first alternative is the consent descriptor a page carries
|
|
16
|
+
* when consent is on (the loader is injected after a grant); the second is the
|
|
17
|
+
* static loader that renders when consent is off. A core test pins both forms
|
|
18
|
+
* to the shipped components, so a change fails loudly here.
|
|
16
19
|
*/
|
|
17
20
|
export declare const ANALYTICS_LOADER_MARKERS: {
|
|
18
|
-
readonly googleAnalytics: readonly ["https://www.googletagmanager.com/gtag/js"];
|
|
19
|
-
readonly fiftyOneLa: readonly ["id=\"LA_COLLECT\"", "https://sdk.51.la/js-sdk-pro.min.js"];
|
|
20
|
-
readonly posthog: readonly ["__hagilightPosthogInitialized"];
|
|
21
|
+
readonly googleAnalytics: readonly [readonly ["data-hagilight-analytics=\"googleAnalytics\""], readonly ["https://www.googletagmanager.com/gtag/js"]];
|
|
22
|
+
readonly fiftyOneLa: readonly [readonly ["data-hagilight-analytics=\"fiftyOneLa\""], readonly ["id=\"LA_COLLECT\"", "https://sdk.51.la/js-sdk-pro.min.js"]];
|
|
23
|
+
readonly posthog: readonly [readonly ["data-hagilight-analytics=\"posthog\""], readonly ["__hagilightPosthogInitialized"]];
|
|
21
24
|
};
|
|
22
25
|
export interface SiteMetadataGenerator {
|
|
23
26
|
readonly name: string;
|
|
@@ -59,6 +62,8 @@ export interface SiteMetadataAnalytics {
|
|
|
59
62
|
export interface SiteMetadataFeatures {
|
|
60
63
|
readonly seo?: boolean;
|
|
61
64
|
readonly promoto?: boolean;
|
|
65
|
+
/** True when the build mounts the consent popup and the analytics gate. */
|
|
66
|
+
readonly consent?: boolean;
|
|
62
67
|
}
|
|
63
68
|
export interface SiteMetadata {
|
|
64
69
|
readonly schemaVersion: typeof SITE_METADATA_SCHEMA_VERSION;
|
package/dist/site-metadata.js
CHANGED
|
@@ -10,18 +10,30 @@ export const SITE_METADATA_SCHEMA_VERSION = 1;
|
|
|
10
10
|
/** Site-relative output path. This is the only place the path is spelled. */
|
|
11
11
|
export const SITE_METADATA_PATH = '.well-known/hagilight.metadata.json';
|
|
12
12
|
/**
|
|
13
|
-
* Substrings that a provider
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Substrings that a provider leaves in built HTML. Each provider is a list of
|
|
14
|
+
* alternatives: a page shows the provider when it carries every marker of one
|
|
15
|
+
* alternative. The first alternative is the consent descriptor a page carries
|
|
16
|
+
* when consent is on (the loader is injected after a grant); the second is the
|
|
17
|
+
* static loader that renders when consent is off. A core test pins both forms
|
|
18
|
+
* to the shipped components, so a change fails loudly here.
|
|
16
19
|
*/
|
|
17
20
|
export const ANALYTICS_LOADER_MARKERS = {
|
|
18
|
-
googleAnalytics: [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
googleAnalytics: [
|
|
22
|
+
['data-hagilight-analytics="googleAnalytics"'],
|
|
23
|
+
['https://www.googletagmanager.com/gtag/js'],
|
|
24
|
+
],
|
|
25
|
+
fiftyOneLa: [
|
|
26
|
+
['data-hagilight-analytics="fiftyOneLa"'],
|
|
27
|
+
['id="LA_COLLECT"', 'https://sdk.51.la/js-sdk-pro.min.js'],
|
|
28
|
+
],
|
|
29
|
+
posthog: [
|
|
30
|
+
['data-hagilight-analytics="posthog"'],
|
|
31
|
+
['__hagilightPosthogInitialized'],
|
|
32
|
+
],
|
|
21
33
|
};
|
|
22
34
|
const DISCOVERY_KEYS = ['sitemap', 'robots', 'rss', 'llms'];
|
|
23
35
|
const ANALYTICS_KEYS = ['googleAnalytics', 'fiftyOneLa', 'posthog'];
|
|
24
|
-
const FEATURE_KEYS = ['seo', 'promoto'];
|
|
36
|
+
const FEATURE_KEYS = ['seo', 'promoto', 'consent'];
|
|
25
37
|
const TOP_LEVEL_KEYS = ['schemaVersion', 'generator', 'site', 'languages', 'build', 'discovery', 'analytics', 'features'];
|
|
26
38
|
function isRecord(value) {
|
|
27
39
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -84,6 +96,7 @@ export function buildSiteMetadata(input) {
|
|
|
84
96
|
const features = {
|
|
85
97
|
...(typeof input.features?.seo === 'boolean' ? { seo: input.features.seo } : {}),
|
|
86
98
|
...(typeof input.features?.promoto === 'boolean' ? { promoto: input.features.promoto } : {}),
|
|
99
|
+
...(typeof input.features?.consent === 'boolean' ? { consent: input.features.consent } : {}),
|
|
87
100
|
};
|
|
88
101
|
return {
|
|
89
102
|
schemaVersion: SITE_METADATA_SCHEMA_VERSION,
|
|
@@ -213,7 +226,7 @@ export function detectAnalyticsLoaders(pages) {
|
|
|
213
226
|
const found = { googleAnalytics: false, fiftyOneLa: false, posthog: false };
|
|
214
227
|
for (const html of pages) {
|
|
215
228
|
for (const provider of ANALYTICS_KEYS) {
|
|
216
|
-
if (!found[provider] && ANALYTICS_LOADER_MARKERS[provider].every((marker) => html.includes(marker))) {
|
|
229
|
+
if (!found[provider] && ANALYTICS_LOADER_MARKERS[provider].some((markers) => markers.every((marker) => html.includes(marker)))) {
|
|
217
230
|
found[provider] = true;
|
|
218
231
|
}
|
|
219
232
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hagicode/hagilight-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1-dev.184.1.830a4c6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared TypeScript utilities, components, and assets for HagiCode Astro and Starlight sites",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,31 @@
|
|
|
17
17
|
"prepack": "tsc -b"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
|
+
"./consent": {
|
|
21
|
+
"types": "./dist/consent.d.ts",
|
|
22
|
+
"default": "./dist/consent.js"
|
|
23
|
+
},
|
|
24
|
+
"./consent-copy": {
|
|
25
|
+
"types": "./dist/consent-copy/index.d.ts",
|
|
26
|
+
"default": "./dist/consent-copy/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./consent-markup": {
|
|
29
|
+
"types": "./dist/consent-markup.d.ts",
|
|
30
|
+
"default": "./dist/consent-markup.js"
|
|
31
|
+
},
|
|
32
|
+
"./CookieConsent": "./CookieConsent.astro",
|
|
33
|
+
"./consent-gate": {
|
|
34
|
+
"types": "./dist/consent-gate.d.ts",
|
|
35
|
+
"default": "./dist/consent-gate.js"
|
|
36
|
+
},
|
|
37
|
+
"./consent-popup": {
|
|
38
|
+
"types": "./dist/consent-popup.d.ts",
|
|
39
|
+
"default": "./dist/consent-popup.js"
|
|
40
|
+
},
|
|
41
|
+
"./consent-mount": {
|
|
42
|
+
"types": "./dist/consent-mount.d.ts",
|
|
43
|
+
"default": "./dist/consent-mount.js"
|
|
44
|
+
},
|
|
20
45
|
"./RootTransit": "./RootTransit.astro",
|
|
21
46
|
"./root-transit": {
|
|
22
47
|
"types": "./dist/root-transit.d.ts",
|
|
@@ -51,6 +76,10 @@
|
|
|
51
76
|
"types": "./dist/seo.d.ts",
|
|
52
77
|
"default": "./dist/seo.js"
|
|
53
78
|
},
|
|
79
|
+
"./entity-definition": {
|
|
80
|
+
"types": "./dist/entity-definition.d.ts",
|
|
81
|
+
"default": "./dist/entity-definition.js"
|
|
82
|
+
},
|
|
54
83
|
"./seo-schema": {
|
|
55
84
|
"types": "./dist/seo-schema.d.ts",
|
|
56
85
|
"default": "./dist/seo-schema.js"
|
|
@@ -87,6 +116,10 @@
|
|
|
87
116
|
"types": "./dist/promoto-banner.d.ts",
|
|
88
117
|
"default": "./dist/promoto-banner.js"
|
|
89
118
|
},
|
|
119
|
+
"./promoto-analytics": {
|
|
120
|
+
"types": "./dist/promoto-analytics.d.ts",
|
|
121
|
+
"default": "./dist/promoto-analytics.js"
|
|
122
|
+
},
|
|
90
123
|
"./analytics-events": {
|
|
91
124
|
"types": "./dist/analytics-events.d.ts",
|
|
92
125
|
"default": "./dist/analytics-events.js"
|
|
@@ -125,6 +158,14 @@
|
|
|
125
158
|
"types": "./dist/posthog.d.ts",
|
|
126
159
|
"default": "./dist/posthog.js"
|
|
127
160
|
},
|
|
161
|
+
"./posthog-events": {
|
|
162
|
+
"types": "./dist/posthog-events.d.ts",
|
|
163
|
+
"default": "./dist/posthog-events.js"
|
|
164
|
+
},
|
|
165
|
+
"./posthog-interactions": {
|
|
166
|
+
"types": "./dist/posthog-interactions.d.ts",
|
|
167
|
+
"default": "./dist/posthog-interactions.js"
|
|
168
|
+
},
|
|
128
169
|
"./Analytics51LA": "./Analytics51LA.astro",
|
|
129
170
|
"./logo.png": "./logo.png",
|
|
130
171
|
"./favicon.ico": "./favicon.ico",
|