@marvalt/digivalt-core 0.2.9 → 0.2.11

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.
@@ -43,7 +43,15 @@ Read via `getPerformanceConfig()` from `@marvalt/digivalt-core/config`. Set to `
43
43
 
44
44
  ## Sitemap (`/sitemap.xml`)
45
45
 
46
- DigiValt apps ship a **Cloudflare Pages Function** at **`functions/sitemap.xml.ts`** that responds at **`/sitemap.xml`**. It reads **`VITE_SEO_SITE_URL`** (or **`SITE_URL`**) for canonical `<loc>` values and loads path slugs from **`public/sitemap-paths.json`** (shape: `{ "paths": ["/", "/pricing"] }`). Update that JSON when you add marketing routes; avoid a static **`public/sitemap.xml`** file, which would override the Function.
46
+ **Runtime:** A **Cloudflare Pages Function** at **`functions/sitemap.xml.ts`** serves **`/sitemap.xml`**. It **`fetch`es `/sitemap-paths.json`** from the deployed static assets and uses **`VITE_SEO_SITE_URL`** (or **`SITE_URL`**) for canonical `<loc>` values (fallback: request origin). Do not add **`public/sitemap.xml`**; it would shadow the Function.
47
+
48
+ **Build time:** **`public/sitemap-paths.json`** is **generated** by **`@marvalt/digivalt-core/generators`** (`generateSitemapPaths`) at the end of **`generateAllData`**, and when **`VITE_IS_LOVABLE=true`** the app’s **`scripts/generate.ts`** still runs that step so paths stay in sync with committed **`wordpress-data.json`**. Sources merged:
49
+
50
+ 1. **`public/sitemap-static-paths.json`** — you maintain this for **React-only / Lovable** public routes (not inferred from code).
51
+ 2. **`navigation_menu`** items in **`wordpress-data.json`** (recursive `url` fields), filtered to **`http(s)`** and the CMS host from **`VITE_WORDPRESS_API_URL`** / **`WORDPRESS_API_URL`**.
52
+ 3. **`link`** on entities in top-level arrays whose keys match **`config.post_types`** (fallback: other top-level arrays minus a fixed skip list). Taxonomy archives are omitted by default.
53
+
54
+ Paths are normalized (no trailing slash except **`/`**), deduped, and sorted. If generation fails, a safe fallback writes **`{ "paths": ["/"] }`**.
47
55
 
48
56
  ## Imports
49
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marvalt/digivalt-core",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Core glue logic and shared context for DigiVAlt frontend applications",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "main": "dist/index.cjs",
@@ -65,7 +65,8 @@
65
65
  "clean": "rimraf dist",
66
66
  "smoke:imports": "node ./scripts/smoke-imports.mjs",
67
67
  "smoke:init": "node ./scripts/smoke-init.cjs",
68
- "smoke": "npm run smoke:imports && npm run smoke:init",
68
+ "smoke:sitemap": "node ./scripts/test-sitemap-paths.cjs",
69
+ "smoke": "npm run smoke:imports && npm run smoke:init && npm run smoke:sitemap",
69
70
  "prepublishOnly": "npm run clean && npm run build && npm run smoke"
70
71
  },
71
72
  "devDependencies": {
@@ -84,7 +84,7 @@ Init will:
84
84
  1. Install **`react-helmet-async`** and wrap your app with **`HelmetProvider`** at the root (next to the router).
85
85
  2. Set at least **`VITE_SEO_SITE_URL`** (no trailing slash), **`VITE_SEO_SITE_NAME`**, **`VITE_SEO_DEFAULT_TITLE`**, **`VITE_SEO_DEFAULT_DESCRIPTION`**, and **`VITE_SEO_DEFAULT_OG_IMAGE`** in Cloudflare Pages / `.env.local`.
86
86
  3. Import **`DigiValtSeoHead`** and **`JsonLd`** from **`@marvalt/digivalt-core/seo`** in your layouts or page components; pass **`pathname`** per route for correct canonical URLs.
87
- 4. **Sitemap:** After init, **`/sitemap.xml`** is served by **`functions/sitemap.xml.ts`** (Cloudflare Pages). Canonical URLs use **`VITE_SEO_SITE_URL`** (or **`SITE_URL`**); edit **`public/sitemap-paths.json`** (`{ "paths": ["/", "/about"] }`) when you add public routes. Do not add a static **`public/sitemap.xml`** (it would shadow the Function).
87
+ 4. **Sitemap:** **`/sitemap.xml`** is served by **`functions/sitemap.xml.ts`**. **`public/sitemap-paths.json`** is **generated** when you run **`npm run build`** (or `generate`): it merges (a) **`public/sitemap-static-paths.json`** — edit this for Lovable/SPA-only routes, (b) URLs from **`navigation_menu`** in **`wordpress-data.json`**, (c) **`link`** pathnames from CPT/post arrays listed under **`config.post_types`**. Only CMS links whose host matches **`VITE_WORDPRESS_API_URL`** / **`WORDPRESS_API_URL`** are included. Canonical `<loc>` values use **`VITE_SEO_SITE_URL`** (or **`SITE_URL`**). Do not add **`public/sitemap.xml`** (it would shadow the Function). With **`VITE_IS_LOVABLE=true`**, static fetch is skipped but sitemap paths are still regenerated from committed JSON.
88
88
  5. Read the full guide shipped with the package: **`node_modules/@marvalt/digivalt-core/docs/SEO-PERFORMANCE.md`** (or in the repo: `digivalt-npm-packages/digivalt-core/docs/SEO-PERFORMANCE.md`).
89
89
 
90
90
  You are fully onboarded and ready to develop offline!
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Serves /sitemap.xml from canonical site URL + public/sitemap-paths.json (no WordPress).
2
+ * Serves /sitemap.xml from canonical site URL + public/sitemap-paths.json (generated at build).
3
3
  * Set VITE_SEO_SITE_URL (or SITE_URL) on Cloudflare Pages for production canonical hosts.
4
4
  */
5
5
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "paths": []
3
+ }
@@ -11,10 +11,13 @@ import { execSync } from 'child_process';
11
11
  */
12
12
 
13
13
  const secrets = {};
14
+ /** Keys we never push from .env / .env.local (local dev or set manually on Cloudflare Pages). */
14
15
  const excludedKeys = new Set([
15
16
  'NODE_ENV',
16
17
  'VITE_IS_LOVABLE',
17
18
  'VITE_LOCAL_DEVELOPMENT',
19
+ 'VITE_AUTH_MODE',
20
+ 'VITE_DEFAULT_MAX_ITEMS',
18
21
  ]);
19
22
 
20
23
  // VITE_SEO_* are often public (verification meta, titles); allow upload when teams store them as Pages secrets.
@@ -27,13 +30,7 @@ const allowedPatterns = [
27
30
  /^VITE_(WORDPRESS|WP|GF|GRAVITY_FORMS|FRONTEND|FRONTENDS|MAUTIC|SUITECRM|SUPABASE|CLOUDFLARE|AUTH|TURNSTILE|CHATWOOT|THEME|GOOGLE_|FACEBOOK_|LINKEDIN_)/,
28
31
  ];
29
32
 
30
- const isAllowedSecretKey = (key) => {
31
- if (excludedKeys.has(key)) {
32
- return false;
33
- }
34
-
35
- return allowedPatterns.some((pattern) => pattern.test(key));
36
- };
33
+ const isAllowedSecretKey = (key) => allowedPatterns.some((pattern) => pattern.test(key));
37
34
 
38
35
  const parseEnvFile = (filePath) => {
39
36
  if (!fs.existsSync(filePath)) return;
@@ -51,6 +48,11 @@ const parseEnvFile = (filePath) => {
51
48
  const key = match[1].trim();
52
49
  let value = match[2].trim();
53
50
 
51
+ if (excludedKeys.has(key)) {
52
+ console.log(`⚠️ Skipping ${key} (DigiVAlt: excluded from Cloudflare bulk upload)`);
53
+ return;
54
+ }
55
+
54
56
  if (!isAllowedSecretKey(key)) {
55
57
  console.log(`⚠️ Skipping ${key} (not in DigiVAlt allowlist)`);
56
58
  return;
@@ -1,18 +1,22 @@
1
- import { generateAllData } from '@marvalt/digivalt-core/generators';
1
+ import { generateAllData, generateSitemapPathsSafe } from '@marvalt/digivalt-core/generators';
2
2
 
3
3
  async function runGenerators() {
4
4
  console.log('🚀 Starting DigiVAlt static data generation for Landing Project...');
5
-
5
+
6
6
  if (process.env.VITE_IS_LOVABLE === 'true') {
7
- console.log('⚡ Lovable Environment Detected (VITE_IS_LOVABLE). Skipping static data generation to use GitHub synced files.');
8
- return;
7
+ console.log(
8
+ '⚡ Lovable Environment Detected (VITE_IS_LOVABLE). Skipping static data fetch; refreshing sitemap paths from committed JSON.'
9
+ );
10
+ await generateSitemapPathsSafe();
11
+ return;
9
12
  }
10
-
13
+
11
14
  try {
12
15
  await generateAllData();
13
16
  console.log('✅ Customized static generation complete!');
14
17
  } catch (error) {
15
18
  console.error('❌ Data fetching encountered an error, but continuing build gracefully:', error);
19
+ await generateSitemapPathsSafe();
16
20
  }
17
21
  }
18
22