@reforma/site 0.0.4 → 0.0.5

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.
@@ -11,10 +11,13 @@ type TrackOptions = {
11
11
  };
12
12
  /**
13
13
  * Start first-party pageview collection for a published Reforma site.
14
- * Reads `NEXT_PUBLIC_REFORMA_ANALYTICS*` env baked on publish. Safe to call
15
- * multiple times — only the first call installs history hooks.
14
+ * Reads the project site config. Only the first call installs history hooks.
16
15
  */
17
- export declare function initAnalytics(options?: AnalyticsOptions): void;
16
+ export declare function initAnalytics(config: {
17
+ analyticsEnabled: boolean;
18
+ analyticsWriteKey: string;
19
+ analyticsEndpoint: string;
20
+ }, options?: AnalyticsOptions): void;
18
21
  /**
19
22
  * Send a named event. `pageview` is traffic (deduped by path); any other name
20
23
  * is a custom event / goal conversion. Optional `props` are string key/values.
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACpB,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AASF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,gBAAqB,GAAG,IAAI,CAqClE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,IAAI,CA6DpE"}
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,KAAK,gBAAgB,GAAG;IACpB,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kDAAkD;IAClD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,YAAY,GAAG;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AASF;;;GAGG;AACH,wBAAgB,aAAa,CACzB,MAAM,EAAE;IAAE,gBAAgB,EAAE,OAAO,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EAC3F,OAAO,GAAE,gBAAqB,GAC/B,IAAI,CAqCN;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,IAAI,CA6DpE"}
package/dist/analytics.js CHANGED
@@ -6,10 +6,9 @@ let lastPath = '';
6
6
  let unhook = null;
7
7
  /**
8
8
  * Start first-party pageview collection for a published Reforma site.
9
- * Reads `NEXT_PUBLIC_REFORMA_ANALYTICS*` env baked on publish. Safe to call
10
- * multiple times — only the first call installs history hooks.
9
+ * Reads the project site config. Only the first call installs history hooks.
11
10
  */
12
- export function initAnalytics(options = {}) {
11
+ export function initAnalytics(config, options = {}) {
13
12
  if (typeof window === 'undefined') {
14
13
  return;
15
14
  }
@@ -23,9 +22,9 @@ export function initAnalytics(options = {}) {
23
22
  return;
24
23
  }
25
24
  started = true;
26
- enabled = process.env.NEXT_PUBLIC_REFORMA_ANALYTICS === '1';
27
- writeKey = process.env.NEXT_PUBLIC_REFORMA_ANALYTICS_KEY?.trim() ?? '';
28
- endpoint = process.env.NEXT_PUBLIC_REFORMA_ANALYTICS_ENDPOINT?.trim() ?? '';
25
+ enabled = config.analyticsEnabled;
26
+ writeKey = config.analyticsWriteKey.trim();
27
+ endpoint = config.analyticsEndpoint.trim();
29
28
  if (!enabled || !writeKey || !endpoint) {
30
29
  enabled = false;
31
30
  return;
@@ -1,6 +1,9 @@
1
- export declare function projectMetadata(fallback: {
1
+ export declare function projectMetadata(defaults: {
2
2
  title: string;
3
3
  description: string;
4
+ }, config: {
5
+ faviconUrl: string;
6
+ indexingEnabled: boolean;
4
7
  }): {
5
8
  title: {
6
9
  template: string;
@@ -18,7 +21,9 @@ export declare function projectMetadata(fallback: {
18
21
  follow: boolean;
19
22
  };
20
23
  };
21
- export declare function projectRobots(): {
24
+ export declare function projectRobots(config: {
25
+ indexingEnabled: boolean;
26
+ }): {
22
27
  rules: {
23
28
  userAgent: string;
24
29
  disallow: string;
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,QAAQ,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE;;QAMpE,QAAQ;QACR,OAAO;;;;QAIP,IAAI;;;;;;;;;EAQf;AAED,wBAAgB,aAAa;IAIrB,KAAK;;;;;;;EAKZ"}
1
+ {"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAC3B,QAAQ,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAChD,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE;;QAOhD,QAAQ;QACR,OAAO;;;;QAIP,IAAI;;;;;;;;;EAQf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,OAAO,CAAA;CAAE;IAI1D,KAAK;;;;;;;EAKZ"}
package/dist/metadata.js CHANGED
@@ -1,12 +1,12 @@
1
- export function projectMetadata(fallback) {
2
- const faviconUrl = process.env.REFORMA_FAVICON_URL || '/favicon.svg';
3
- const indexingOn = process.env.REFORMA_INDEXING !== '0';
1
+ export function projectMetadata(defaults, config) {
2
+ const faviconUrl = config.faviconUrl || '/favicon.svg';
3
+ const indexingOn = config.indexingEnabled;
4
4
  return {
5
5
  title: {
6
6
  template: '%s',
7
- default: process.env.REFORMA_DEFAULT_TITLE || fallback.title,
7
+ default: defaults.title,
8
8
  },
9
- description: process.env.REFORMA_DEFAULT_DESCRIPTION || fallback.description,
9
+ description: defaults.description,
10
10
  icons: {
11
11
  icon: faviconUrl.endsWith('.svg')
12
12
  ? { url: faviconUrl, type: 'image/svg+xml' }
@@ -17,8 +17,8 @@ export function projectMetadata(fallback) {
17
17
  : { index: false, follow: false },
18
18
  };
19
19
  }
20
- export function projectRobots() {
21
- const blocked = process.env.REFORMA_INDEXING === '0';
20
+ export function projectRobots(config) {
21
+ const blocked = !config.indexingEnabled;
22
22
  return {
23
23
  rules: {
24
24
  userAgent: '*',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reforma/site",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Visitor runtime for a Reforma site: mode, publish metadata, and the PostCSS url guard.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",