From 1c6d3ca1203900c16f91d9f127724e811a74fde9 Mon Sep 17 00:00:00 2001 From: multipleof4 Date: Wed, 25 Feb 2026 10:14:31 -0800 Subject: [PATCH] Delete build.js --- build.js | 92 -------------------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 build.js diff --git a/build.js b/build.js deleted file mode 100644 index cd85d79..0000000 --- a/build.js +++ /dev/null @@ -1,92 +0,0 @@ -import { readFileSync, writeFileSync, mkdirSync, cpSync, readdirSync, existsSync, statSync } from 'fs' -import { join } from 'path' -import matter from 'gray-matter' -import { marked } from 'marked' - -const ARTICLES = 'articles' -const DIST = 'dist' -const TEMPLATES = 'templates' -const STATIC = 'static' - -const template = n => readFileSync(join(TEMPLATES, n), 'utf-8') -const articleTmpl = template('article.html') -const homeTmpl = template('home.html') - -const render = (tpl, data) => - tpl.replace(/{{\s*([a-zA-Z0-9_]+)\s*}}/g, (_, key) => `${data[key] ?? ''}`) - -const fmtDateLong = d => - d ? new Date(d).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) : '' - -const fmtDateIso = d => (d ? new Date(d).toISOString().split('T')[0] : '') - -mkdirSync(DIST, { recursive: true }) - -if (existsSync(STATIC)) cpSync(STATIC, DIST, { recursive: true }) - -const articles = [] - -for (const slug of readdirSync(ARTICLES)) { - const dir = join(ARTICLES, slug) - if (!statSync(dir).isDirectory()) continue - - const mdPath = join(dir, 'index.md') - if (!existsSync(mdPath)) continue - - const { data, content } = matter(readFileSync(mdPath, 'utf-8')) - const html = marked(content) - - const outDir = join(DIST, slug) - mkdirSync(outDir, { recursive: true }) - - for (const f of readdirSync(dir)) { - if (f === 'index.md') continue - cpSync(join(dir, f), join(outDir, f), { recursive: true }) - } - - const page = render(articleTmpl, { - title: data.title || slug, - date: fmtDateLong(data.date), - date_iso: fmtDateIso(data.date), - tags: (data.tags || []) - .map( - t => - `${t}` - ) - .join(' '), - excerpt: data.excerpt || '', - slug, - body: html - }) - - writeFileSync(join(outDir, 'index.html'), page) - articles.push({ slug, ...data }) - console.log(`āœ… ${slug}`) -} - -articles.sort((a, b) => new Date(b.date) - new Date(a.date)) - -const articleListHtml = articles - .map( - a => ` - -
-
-

${a.title}

- -
- ${a.excerpt ? `

${a.excerpt}

` : ''} -
${(a.tags || []) - .map( - t => - `${t}` - ) - .join('')}
-
-
` - ) - .join('\n') - -const home = render(homeTmpl, { articles: articleListHtml }) -writeFileSync(join(DIST, 'index.html'), home) -console.log(`\nšŸ  index.html → ${articles.length} article(s)`)