💥 Wipe old stack, replace with clean static blog engine
This commit is contained in:
commit
5401ac287a
27 changed files with 9024 additions and 0 deletions
20
build.js
Normal file
20
build.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { marked } from 'marked';
|
||||
|
||||
const postsDir = './posts';
|
||||
const outputFile = './posts.js';
|
||||
|
||||
const files = fs.readdirSync(postsDir).filter(f => f.endsWith('.md'));
|
||||
|
||||
const posts = files.map(file => {
|
||||
const filepath = path.join(postsDir, file);
|
||||
const raw = fs.readFileSync(filepath, 'utf-8');
|
||||
const html = marked.parse(raw);
|
||||
return { file, content: html };
|
||||
});
|
||||
|
||||
const output = `document.getElementById("content").innerHTML = \`${posts.map(p => `<article>${p.content}</article>`).join("")}\`;`;
|
||||
|
||||
fs.writeFileSync(outputFile, output);
|
||||
console.log("✅ Blog built to posts.js");
|
Loading…
Add table
Add a link
Reference in a new issue