diff --git a/index.html b/index.html index 38a5fa7..0e2d4af 100644 --- a/index.html +++ b/index.html @@ -17,6 +17,8 @@ + +
diff --git a/scripts/rss.ts b/scripts/rss.ts new file mode 100644 index 0000000..fd93476 --- /dev/null +++ b/scripts/rss.ts @@ -0,0 +1,120 @@ +import { readFileSync, readdirSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'; +import { join, resolve } from 'node:path'; + +export interface RssOptions { + siteUrl: string; + title: string; + description: string; + blogDir?: string; + outFile?: string; +} + +interface Meta { + slug: string; + title: string; + date: string; + description?: string; + tags?: string[]; + draft?: boolean; + content: string; +} + +function parseValue(value: string): string | string[] | boolean { + const t = value.trim(); + if (t === 'true') return true; + if (t === 'false') return false; + if (t.startsWith('[') && t.endsWith(']')) { + return t.slice(1, -1).split(',').map((s) => s.trim().replace(/^['"]|['"]$/g, '')).filter(Boolean); + } + return t.replace(/^['"]|['"]$/g, ''); +} + +function parseFrontmatter(raw: string): { data: RecordNotes on self-hosting, linux, and whatever else. diff --git a/vite.config.ts b/vite.config.ts index a9b992f..b6cb8fa 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,6 +2,7 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import path from "path"; import { componentTagger } from "lovable-tagger"; +import { rssPlugin } from "./scripts/rss"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ @@ -12,7 +13,15 @@ export default defineConfig(({ mode }) => ({ overlay: false, }, }, - plugins: [react(), mode === "development" && componentTagger()].filter(Boolean), + plugins: [ + react(), + mode === "development" && componentTagger(), + rssPlugin({ + siteUrl: "https://damaj.tech", + title: "Damaj — Blog", + description: "Writing on engineering, systems, and craft.", + }), + ].filter(Boolean), resolve: { alias: { "@": path.resolve(__dirname, "./src"),