feat: serve site content from Appwrite TablesDB with .md fallback
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.
This commit is contained in:
1 parent
2b775cbf99
commit
80577d6404
17 files changed
+872
-131
No files matched your search
+21
-1
@@ -4,11 +4,31 @@ import sitemap from "@astrojs/sitemap"
|
||||
import solidJs from "@astrojs/solid-js"
|
||||
import node from "@astrojs/node"
|
||||
import tailwindcss from "@tailwindcss/vite"
|
||||
import { readdirSync } from "node:fs"
|
||||
|
||||
// The blog/projects/legal detail pages are served from Appwrite at request
|
||||
// time (prerender = false), so they no longer appear in the build-time route
|
||||
// list the sitemap integration collects. Compute their URLs from the bundled
|
||||
// markdown copies — the same files scripts/appwrite-migrate.mjs imports, and
|
||||
// the fallback source — so the sitemap stays complete without a build-time
|
||||
// network call.
|
||||
function contentPages() {
|
||||
const site = "https://spaghet.io"
|
||||
const slugs = (dir) =>
|
||||
readdirSync(new URL(`./src/content/${dir}/`, import.meta.url))
|
||||
.filter((f) => f.endsWith(".md"))
|
||||
.map((f) => f.replace(/\.md$/, ""))
|
||||
return [
|
||||
...slugs("blog").map((s) => `${site}/blog/${s}/`),
|
||||
...slugs("projects").map((s) => `${site}/projects/${s}/`),
|
||||
...slugs("legal").map((s) => `${site}/legal/${s}/`),
|
||||
]
|
||||
}
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
site: "https://spaghet.io",
|
||||
integrations: [mdx(), sitemap(), solidJs()],
|
||||
integrations: [mdx(), sitemap({ customPages: contentPages() }), solidJs()],
|
||||
output: "server",
|
||||
adapter: node({ mode: "ssr" }),
|
||||
markdown: {
|
||||
|
||||
Reference in new issue
Block a user