@brandon_m_behring/book-scaffold-astro 4.23.0 → 4.24.0

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.
@@ -10,17 +10,18 @@ interface Props {
10
10
  }
11
11
  const { currentId } = Astro.props;
12
12
  const { prev, next } = await getNeighbors(currentId);
13
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
13
14
  ---
14
15
  {(prev || next) && (
15
16
  <nav class="chapter-nav" aria-label="Chapter navigation">
16
17
  {prev && (
17
- <a href={`/${prev.id}/`} class="prev">
18
+ <a href={`${baseUrl}chapters/${prev.id}/`} class="prev">
18
19
  <span class="nav-label">← Previous</span>
19
20
  <span class="nav-title">{prev.data.title}</span>
20
21
  </a>
21
22
  )}
22
23
  {next && (
23
- <a href={`/${next.id}/`} class="next">
24
+ <a href={`${baseUrl}chapters/${next.id}/`} class="next">
24
25
  <span class="nav-label">Next →</span>
25
26
  <span class="nav-title">{next.data.title}</span>
26
27
  </a>
@@ -45,6 +45,7 @@ interface Props {
45
45
  }
46
46
 
47
47
  const { key, page } = Astro.props;
48
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
48
49
  const entry = map[key];
49
50
  if (!entry) {
50
51
  throw new Error(
@@ -66,6 +67,6 @@ else authorText = `${surname(authors[0])} et al.`;
66
67
  const year = entry.issued?.['date-parts']?.[0]?.[0] ?? 'n.d.';
67
68
  const yearText = page ? `${year}, p. ${page}` : `${year}`;
68
69
  ---
69
- <a href={`/references#${key}`} class="cite" title={entry.title ?? key}>
70
+ <a href={`${baseUrl}references#${key}`} class="cite" title={entry.title ?? key}>
70
71
  {authorText} ({yearText})
71
72
  </a>
@@ -27,6 +27,7 @@ interface Props {
27
27
  title?: string;
28
28
  }
29
29
  const { part, title } = Astro.props;
30
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
30
31
 
31
32
  // Reuse the build-exercises index (keyed by chapter slug). Project-root-relative
32
33
  // glob (the tips.astro / exercises.astro lesson) so it resolves across consumers.
@@ -65,7 +66,7 @@ const heading = title ?? `Part ${part} Review`;
65
66
  </p>
66
67
  {groups.map((g) => (
67
68
  <section class="part-review-chapter">
68
- <h3 class="part-review-chapter-title"><a href={`/chapters/${g.chapter}/`}>{g.chapter}</a></h3>
69
+ <h3 class="part-review-chapter-title"><a href={`${baseUrl}chapters/${g.chapter}/`}>{g.chapter}</a></h3>
69
70
  <ol class="part-review-list">
70
71
  {g.exercises.map((ex) => (
71
72
  <li id={`review-${ex.id}`} class="part-review-item">
@@ -54,7 +54,7 @@ const asLink = appendix && !onAnswersRoute;
54
54
  ---
55
55
  {asLink ? (
56
56
  <p class="question-rationale-ref">
57
- <a href={`/answers#answer-${forId}`}>{title} →</a>
57
+ <a href={`${basePath}/answers#answer-${forId}`}>{title} →</a>
58
58
  </p>
59
59
  ) : (
60
60
  <details class="question-rationale">
@@ -28,6 +28,7 @@ import { academicPartHeading } from '../src/lib/academic-parts';
28
28
  const profile = import.meta.env.BOOK_PROFILE ?? 'minimal';
29
29
  const siteTitle = bookConfig.title ?? 'Book';
30
30
  const siteSubtitle = bookConfig.subtitle ?? 'A scaffold-astro book';
31
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
31
32
 
32
33
  // Academic profile: part is a string enum. `academicParts` (schemas.ts) is
33
34
  // the canonical order, shared with the renderer and ChapterHeader (#95); the
@@ -91,8 +92,10 @@ for (const r of rows) {
91
92
  }
92
93
 
93
94
  const currentPath = Astro.url.pathname;
95
+ const chaptersIndexHref = `${baseUrl}chapters/`;
96
+ const referencesHref = `${baseUrl}references/`;
94
97
  function isCurrent(id: string): boolean {
95
- return currentPath === `/chapters/${id}/` || currentPath === `/chapters/${id}`;
98
+ return currentPath === `${baseUrl}chapters/${id}/` || currentPath === `${baseUrl}chapters/${id}`;
96
99
  }
97
100
 
98
101
  function partLabel(key: string): string {
@@ -103,22 +106,22 @@ function partLabel(key: string): string {
103
106
 
104
107
  <aside class="sidebar" aria-label="Chapter navigation">
105
108
  <div class="sidebar-inner">
106
- <a href="/" class="sidebar-home">
109
+ <a href={baseUrl} class="sidebar-home">
107
110
  <strong>{siteTitle}</strong>
108
111
  <span class="sidebar-subtitle">{siteSubtitle}</span>
109
112
  </a>
110
113
 
111
114
  <nav class="sidebar-nav">
112
115
  <a
113
- href="/chapters/"
114
- class={`sidebar-link sidebar-link-index ${currentPath === '/chapters/' ? 'is-current' : ''}`}
116
+ href={chaptersIndexHref}
117
+ class={`sidebar-link sidebar-link-index ${currentPath === chaptersIndexHref ? 'is-current' : ''}`}
115
118
  >
116
119
  All chapters
117
120
  </a>
118
121
  {profile === 'academic' && (
119
122
  <a
120
- href="/references/"
121
- class={`sidebar-link sidebar-link-index ${currentPath === '/references/' ? 'is-current' : ''}`}
123
+ href={referencesHref}
124
+ class={`sidebar-link sidebar-link-index ${currentPath === referencesHref ? 'is-current' : ''}`}
122
125
  >
123
126
  References
124
127
  </a>
@@ -131,7 +134,7 @@ function partLabel(key: string): string {
131
134
  {list.map((r) => (
132
135
  <li>
133
136
  <a
134
- href={`/chapters/${r.id}/`}
137
+ href={`${baseUrl}chapters/${r.id}/`}
135
138
  class={`sidebar-link ${isCurrent(r.id) ? 'is-current' : ''}`}
136
139
  >
137
140
  <span class="sidebar-week">{r.prefix}</span>
@@ -17,8 +17,9 @@ interface Props {
17
17
  id: string;
18
18
  }
19
19
  const { id } = Astro.props;
20
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
20
21
  ---
21
- <a href={`/glossary#term-${id}`} class="term-link"><slot /></a>
22
+ <a href={`${baseUrl}glossary#term-${id}`} class="term-link"><slot /></a>
22
23
 
23
24
  <style>
24
25
  .term-link {
@@ -20,6 +20,7 @@ const tipsModules = import.meta.glob<{ default: Array<{ n: number; title: string
20
20
  { eager: true },
21
21
  );
22
22
  const tips = tipsModules['/src/data/tips.json']?.default ?? [];
23
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
23
24
  ---
24
25
  <aside class="tips-card" role="contentinfo">
25
26
  <h2 class="tips-card-title">Tips</h2>
@@ -33,7 +34,7 @@ const tips = tipsModules['/src/data/tips.json']?.default ?? [];
33
34
  <ol class="tips-card-list">
34
35
  {tips.map((tip) => (
35
36
  <li class="tips-card-item">
36
- <a href={`/tips#tip-${tip.n}`} class="tips-card-link">
37
+ <a href={`${baseUrl}tips#tip-${tip.n}`} class="tips-card-link">
37
38
  <span class="tips-card-number">{tip.n}.</span>
38
39
  <strong class="tips-card-rule">{tip.title}</strong>
39
40
  </a>
@@ -99,13 +99,14 @@ const absoluteOgImage = resolvedOgImage
99
99
  const twitterHandle = bookConfig.seo?.twitterHandle ?? null;
100
100
  const ogSiteName = bookConfig.title ?? title;
101
101
  const ogDescription = description ?? bookConfig.description ?? '';
102
+ const baseUrl = import.meta.env.BASE_URL ?? '/';
102
103
  ---
103
104
 
104
105
  <!doctype html>
105
106
  <html lang={lang}>
106
107
  <head>
107
108
  <meta charset="utf-8" />
108
- <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
109
+ <link rel="icon" type="image/svg+xml" href={`${baseUrl}favicon.svg`} />
109
110
  <meta name="viewport" content="width=device-width, initial-scale=1" />
110
111
  <meta name="color-scheme" content="light dark" />
111
112
  <meta name="generator" content={Astro.generator} />
@@ -119,7 +120,7 @@ const ogDescription = description ?? bookConfig.description ?? '';
119
120
  OG tags). sitemap link points at @astrojs/sitemap's auto-emitted
120
121
  index. */}
121
122
  <link rel="canonical" href={canonicalURL} />
122
- <link rel="sitemap" type="application/xml" href="/sitemap-index.xml" />
123
+ <link rel="sitemap" type="application/xml" href={`${baseUrl}sitemap-index.xml`} />
123
124
  <meta property="og:title" content={title} />
124
125
  {ogDescription && <meta property="og:description" content={ogDescription} />}
125
126
  <meta property="og:url" content={canonicalURL} />
@@ -150,7 +151,7 @@ const ogDescription = description ?? bookConfig.description ?? '';
150
151
  {showToolsChrome && <ToolFilter client:idle />}
151
152
  {showToolsChrome && <VersionSelector client:idle />}
152
153
  <a
153
- href="/search/"
154
+ href={`${baseUrl}search/`}
154
155
  class="chrome-button"
155
156
  aria-label="Search the book"
156
157
  title="Search"
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.23.0",
4
+ "version": "4.24.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Brandon Behring",