Add feeds, sitemap, search, tags, and per-post nav/TOC/series/related

- src/site.config.ts: minimal site metadata (title, description,
  base URL, nav, tag descriptions) ported from the legacy zola.toml
  as a placeholder pending real design/copy.
- RSS (@astrojs/rss) and JSON Feed endpoints, sitemap
  (@astrojs/sitemap), robots.txt.
- Base.astro: meta description (site-wide default or per-page
  override via llms_description/description), RSS/JSON feed
  <link rel=alternate>, and a webmention endpoint link (plumbing
  only — needs the domain registered on webmention.io to do
  anything).
- toml-content-loader.ts: marked renderer now assigns heading ids
  and collects them into rendered.metadata.headings, so
  render(entry) exposes headings the same way a built-in Markdown
  loader would.
- Writing detail page: table of contents, prev/next navigation,
  series-nav (uses the existing extra.series/series_index fields),
  and tag-overlap related posts.
- Tags index + per-tag pages, tag links wired in from writing cards.
- Pagefind: indexes the build output as part of `pnpm build`
  (astro build && pagefind --site dist), plus a /search/ page using
  Pagefind's default UI.

Verified: astro check clean, full build succeeds (feeds/sitemap/
pagefind all generate correctly), and manually exercised /search/
(real query, highlighted results) and /tags/ in a browser against
the built site.
This commit is contained in:
2026-08-30 19:04:25 +03:00
parent 7b857d4be7
commit 02a7a6197f
13 changed files with 1145 additions and 9 deletions
+93 -3
View File
@@ -11,17 +11,107 @@ export async function getStaticPaths() {
}
const { entry } = Astro.props;
const { Content } = await render(entry);
const { Content, headings } = await render(entry);
const allWritings = (
await getCollection("writings", ({ data }) => !data.draft)
).sort((a, b) => a.data.date.valueOf() - b.data.date.valueOf());
const index = allWritings.findIndex((w) => w.id === entry.id);
const prev = index > 0 ? allWritings[index - 1] : undefined;
const next =
index < allWritings.length - 1 ? allWritings[index + 1] : undefined;
const series = entry.data.extra?.series;
const seriesEntries = series
? allWritings
.filter((w) => w.data.extra?.series === series)
.sort(
(a, b) =>
(a.data.extra?.series_index ?? 0) - (b.data.extra?.series_index ?? 0),
)
: [];
const tags = entry.data.taxonomies?.tags ?? [];
const related = tags.length
? allWritings
.filter((w) => w.id !== entry.id)
.map((w) => ({
entry: w,
overlap: (w.data.taxonomies?.tags ?? []).filter((t) => tags.includes(t))
.length,
}))
.filter((w) => w.overlap > 0)
.sort((a, b) => b.overlap - a.overlap)
.slice(0, 3)
.map((w) => w.entry)
: [];
const description =
entry.data.extra?.llms_description ?? entry.data.description;
const tocHeadings = headings.filter((h) => h.depth <= 3);
---
<Base title={entry.data.title}>
<Base title={entry.data.title} description={description}>
<h1>{entry.data.title}</h1>
<p class="meta">
{entry.data.date.toDateString()}
{entry.data.updated && <> · updated {entry.data.updated.toDateString()}</>}
</p>
{entry.data.taxonomies?.tags.map((tag) => <span class="tag">#{tag}</span>)}
{tags.map((tag) => <a class="tag" href={`/tags/${tag}/`}>#{tag}</a>)}
{
series && (
<nav class="series-nav" aria-label={`Post series: ${series}`}>
<p class="meta">
Series: {series} ({(entry.data.extra?.series_index ?? 0)} / {seriesEntries.length})
</p>
<ol>
{seriesEntries.map((w) => (
<li aria-current={w.id === entry.id ? "page" : undefined}>
<a href={`/writings/${w.id}/`}>{w.data.title}</a>
</li>
))}
</ol>
</nav>
)
}
{
tocHeadings.length > 0 && (
<nav class="toc" aria-label="Table of contents">
<p class="meta">Table of Contents</p>
<ul>
{tocHeadings.map((h) => (
<li style={{ marginLeft: `${(h.depth - 2) * 1}rem` }}>
<a href={`#${h.slug}`}>{h.text}</a>
</li>
))}
</ul>
</nav>
)
}
<article>
<Content />
</article>
<nav class="post-nav" aria-label="Post navigation">
{prev && <a href={`/writings/${prev.id}/`}>← {prev.data.title}</a>}
{next && <a href={`/writings/${next.id}/`}>{next.data.title} →</a>}
</nav>
{
related.length > 0 && (
<section>
<h2>Related Posts</h2>
{related.map((w) => (
<div class="card">
<h3>
<a href={`/writings/${w.id}/`}>{w.data.title}</a>
</h3>
</div>
))}
</section>
)
}
</Base>