feat(structure): compact archive + tag pages + hero/featured, and fix site search
Deploy / build (push) Failing after 13m52s
Deploy / build (push) Failing after 13m52s
Found a real bug while verifying the nav search: /pagefind/pagefind.js is an ES
module that defines no window.Pagefind, but Search.astro loaded it with a classic
<script src> and read window.Pagefind — so every query answered "Search is
unavailable." (confirmed live before the fix). Now a dynamic import; the specifier
must be a variable or Rollup resolves it at build time and the build fails.
Measured before/after in a real browser:
- archive /posts/ + /zh/posts/: 18,220px -> 3,788px (71 rows at 44px, grouped by
year) with a client-side filter (title/tags/description text, category chips,
14 tag chips, zero requests). Tested: "nginx" -> 6 rows, chip devops -> 28.
- tag pages for tags with >= 3 posts. Measured 235 distinct tags (an earlier brief
claimed 74), 156 used exactly once — pages only where a topic exists: 40 tags ->
80 pages, build 165 -> 245 pages. Pills link only when a page exists.
- homepage + ZH homepage: hero (288px) with the real scale claim, three CTAs, a
fixed Featured 4 (scale -> automation -> observability -> a delivered result),
Latest 10 -> 6. ZH hero had linked "关于我" to the English /about/.
- long code blocks collapse above 420px with an Expand button + gradient, copy
button still copies the whole block (verified on the 1010px block).
- search is visible ("⌕ Search /" pill, "/" plus the existing Ctrl/Cmd+K) and the
zero-result screen offers topic chips instead of a dead end.
Docs: project-state B3 entry, ops-runbook Pagefind gotcha.
This commit is contained in:
1 parent
8619e48271
commit
f4008d9e8b
15 files changed
+669
-60
No files matched your search
@@ -32,6 +32,14 @@ Markdown (src/content/posts) → Astro build (dist/) → Gitea Actions → act_r
|
||||
|
||||
## Build pitfalls (from prior Astro work — check these first)
|
||||
|
||||
- **Pagefind is an ES module and exposes no window global.** `dist/pagefind/pagefind.js`
|
||||
ends with `export { search, debouncedSearch, … }`. Load it with a dynamic `import()`, never
|
||||
a classic `<script src>` + `window.Pagefind` — that combination silently made every search
|
||||
answer "Search is unavailable." for as long as the overlay existed. The specifier must be a
|
||||
**variable** (`const url = '/pagefind/pagefind.js'; await import(/* @vite-ignore */ url)`)
|
||||
because Rollup resolves a literal dynamic-import path at build time and fails on a file that
|
||||
does not exist until after the search index is generated.
|
||||
|
||||
- **No JSX helper components in frontmatter** — inline JSX directly in `.map()` calls, or the build fails with `Expected ">" but found "class"`.
|
||||
- **Import depth** — `src/pages/*.astro` use `../layouts/…`; subdirs use `../../`. Wrong level = `Could not resolve`.
|
||||
- **Footer must render AFTER `<main>`** — a shared header+footer component renders footer above content otherwise.
|
||||
|
||||
Reference in new issue
Block a user