Replace astro:content getCollection() reads in all 9 content pages with src/lib/content-source.ts: Appwrite TablesDB (spaghet-home database on appwrite.spaghet.io) first, bundled src/content/*.md fallback on a cold-cache outage. Blog/project/legal detail pages flip from prerender to SSR (content now arrives at request time); sitemap keeps every detail URL via customPages computed from the bundled .md copies. - src/lib/appwrite.ts: TablesDB service (node-appwrite), markdown rendered through Astro's own satteri+shiki pipeline (dual-theme, same config as astro.config.mjs) — article HTML verified byte-identical to production. Public reads: tables grant read(any), no secret required. 60s in-process cache, stale-serving on refresh failure. - src/lib/__tests__/appwrite.test.ts: 11 tests mocking the SDK boundary (the SDK binds its own fetch, so global stubs do not intercept it). - Draft posts now 302 to /blog and drop off listings/RSS/search at request time instead of at build time. - astro check: 0 errors; vitest: 94 pass; build clean; end-to-end verified against live Appwrite and against a forced outage.
41 lines
1.5 KiB
Plaintext
41 lines
1.5 KiB
Plaintext
---
|
|
import PageLayout from "@layouts/PageLayout.astro"
|
|
import TopLayout from "@layouts/TopLayout.astro"
|
|
import BottomLayout from "@layouts/BottomLayout.astro"
|
|
import FilteredList from "@components/FilteredList"
|
|
import { BLOG } from "@consts"
|
|
import { parseFilterParams } from "@lib/filters"
|
|
import { listSlimContent } from "@lib/content-source"
|
|
|
|
// Only the fields the cards and the filters read. `content` was serialized into
|
|
// the island's props on every request and never matched against — the markdown
|
|
// body is the single largest thing on this page. Appwrite TablesDB first,
|
|
// bundled .md fallback (src/lib/content-source.ts); ordering is already
|
|
// newest-first with the byDateDesc tie-break.
|
|
const slim = await listSlimContent("blog")
|
|
const posts = slim.map((entry) => ({
|
|
id: entry.id,
|
|
title: entry.data.title,
|
|
summary: entry.data.summary,
|
|
date: entry.data.date.toISOString(),
|
|
tags: entry.data.tags,
|
|
}))
|
|
|
|
// Frontmatter runs on the server, so the initial filter state has to come from
|
|
// the request URL rather than `window.location` (see src/pages/search/index.astro).
|
|
const initial = parseFilterParams(Astro.url.searchParams)
|
|
---
|
|
|
|
<PageLayout title={BLOG.TITLE} description={BLOG.DESCRIPTION}>
|
|
<TopLayout>
|
|
<div class="animate page-heading">
|
|
{BLOG.TITLE}
|
|
</div>
|
|
</TopLayout>
|
|
<BottomLayout>
|
|
<div class="animate">
|
|
<FilteredList client:load collection="blog" entries={posts} initial={initial} />
|
|
</div>
|
|
</BottomLayout>
|
|
</PageLayout>
|