@brandon_m_behring/book-scaffold-astro 4.5.0 → 4.5.1

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/dist/index.mjs CHANGED
@@ -824,6 +824,23 @@ function defineMdxComponents(components) {
824
824
  }
825
825
 
826
826
  // src/integration.ts
827
+ var LANDING_VIRTUAL_ID = "virtual:book-scaffold/landing-config";
828
+ var LANDING_RESOLVED_ID = "\0" + LANDING_VIRTUAL_ID;
829
+ function makeLandingConfigVitePlugin(config) {
830
+ const serialized = `export default ${JSON.stringify(config)};`;
831
+ return {
832
+ name: "book-scaffold:landing-config",
833
+ enforce: "pre",
834
+ resolveId(id) {
835
+ if (id === LANDING_VIRTUAL_ID) return LANDING_RESOLVED_ID;
836
+ return null;
837
+ },
838
+ load(id) {
839
+ if (id !== LANDING_RESOLVED_ID) return null;
840
+ return serialized;
841
+ }
842
+ };
843
+ }
827
844
  var PACKAGE_NAME = "@brandon_m_behring/book-scaffold-astro";
828
845
  var ROUTE_REGISTRY = {
829
846
  references: { pattern: "/references", file: "references.astro" },
@@ -918,17 +935,22 @@ function bookScaffoldIntegration(opts) {
918
935
  const enabledRouteNames = Object.entries(enabledRoutes).filter(([, on]) => on).map(([name]) => name);
919
936
  updateConfig({
920
937
  vite: {
921
- plugins: [makeMdxComponentsVitePlugin(resolvedMdxPath)],
938
+ plugins: [
939
+ makeMdxComponentsVitePlugin(resolvedMdxPath),
940
+ makeLandingConfigVitePlugin({
941
+ title: title ?? null,
942
+ description: description ?? null,
943
+ portfolio: portfolio ?? false,
944
+ enabledRoutes: enabledRouteNames
945
+ })
946
+ ],
922
947
  define: {
948
+ // Preset/profile stay as env vars — preference-flag pattern where
949
+ // env-based override IS the convention (resolvePreset reads from
950
+ // process.env / .env explicitly). Config values (title, etc.) now
951
+ // route through the virtual module above to avoid that override.
923
952
  "import.meta.env.BOOK_PRESET": presetLiteral,
924
- "import.meta.env.BOOK_PROFILE": presetLiteral,
925
- // v4.5.0: landing-page data. JSON.stringify on undefined → 'undefined'
926
- // (which evaluates to JavaScript undefined at use site); on object →
927
- // the JSON literal; on false → 'false'.
928
- "import.meta.env.BOOK_TITLE": JSON.stringify(title ?? null),
929
- "import.meta.env.BOOK_DESCRIPTION": JSON.stringify(description ?? null),
930
- "import.meta.env.BOOK_PORTFOLIO": JSON.stringify(portfolio ?? null),
931
- "import.meta.env.BOOK_ROUTES_ENABLED": JSON.stringify(enabledRouteNames)
953
+ "import.meta.env.BOOK_PROFILE": presetLiteral
932
954
  }
933
955
  }
934
956
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brandon_m_behring/book-scaffold-astro",
3
3
  "description": "Astro 6 + MDX toolkit for long-form technical books. Profile-aware (academic / tools / minimal); ships Tufte typography, KaTeX, BibTeX citations, Pagefind, Cloudflare Workers deploy. See PACKAGE_DESIGN.md for the API contract.",
4
- "version": "4.5.0",
4
+ "version": "4.5.1",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Brandon Behring",
package/pages/index.astro CHANGED
@@ -1,14 +1,22 @@
1
1
  ---
2
2
  /**
3
- * /index — minimal default landing page (v4.5.0).
3
+ * /index — minimal default landing page (v4.5.0; landing-config source
4
+ * refactored in v4.5.1 from env vars to virtual module).
4
5
  *
5
6
  * Auto-injected by bookScaffoldIntegration when routes.landing === true
6
7
  * (default for every profile). Consumers with their own src/pages/index.astro
7
8
  * override automatically — file-system routes win over injectRoute, no extra
8
9
  * config needed.
9
10
  *
10
- * Reads book identity + portfolio + enabled-routes from vite.define-injected
11
- * env vars (see integration.ts §4.5.0). Renders:
11
+ * Reads book identity + portfolio + enabled-routes from the
12
+ * `virtual:book-scaffold/landing-config` virtual module exposed by
13
+ * makeLandingConfigVitePlugin (see integration.ts §4.5.1). v4.5.0 used
14
+ * import.meta.env.BOOK_* env vars; that pattern was vulnerable to silent
15
+ * override by consumer .env files (caught during DML deploy when a stale
16
+ * `BOOK_TITLE=web` in web/.env overrode defineBookConfig({title})). The
17
+ * virtual module isolates landing config from any env-based override.
18
+ *
19
+ * Renders:
12
20
  * - h1 with book title (fallback: 'book-scaffold-astro')
13
21
  * - lead paragraph with description (omitted if not set)
14
22
  * - "Read" list of links to enabled scaffold routes (filtered to only
@@ -23,13 +31,12 @@
23
31
  * or defineBookConfig({ portfolio: false })
24
32
  */
25
33
  import Base from '../layouts/Base.astro';
34
+ import bookConfig from 'virtual:book-scaffold/landing-config';
26
35
 
27
- // Vite-injected at build time. JSON.stringify(value ?? null) is the
28
- // integration's convention; null means "not set", an object/string means real value.
29
- const title = (import.meta.env.BOOK_TITLE as string | null) ?? 'book-scaffold-astro';
30
- const description = import.meta.env.BOOK_DESCRIPTION as string | null;
31
- const portfolio = import.meta.env.BOOK_PORTFOLIO as { url: string; label: string } | false | null;
32
- const enabledRoutes = (import.meta.env.BOOK_ROUTES_ENABLED as string[] | undefined) ?? [];
36
+ const title = bookConfig.title ?? 'book-scaffold-astro';
37
+ const description = bookConfig.description;
38
+ const portfolio = bookConfig.portfolio;
39
+ const enabledRoutes = bookConfig.enabledRoutes;
33
40
 
34
41
  // Map from internal route name → display label + URL. Only routes that
35
42
  // produce a single landing-list entry are listed here (frontmatter is a