Skip to content

Commit 1a5913d

Browse files
committed
fixes maybe
1 parent 989a864 commit 1a5913d

File tree

3 files changed

+4331
-26
lines changed

3 files changed

+4331
-26
lines changed

.scripts/transform.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { statSync, readFileSync, writeFileSync, readdirSync } from "fs";
2+
import { join } from "path";
3+
4+
function transform(filePath) {
5+
const stats = statSync(filePath);
6+
const lastWriteDate = new Date(stats.mtime).toISOString().split("T")[0];
7+
console.log(`Transforming ${filePath} last modified at ${lastWriteDate}`);
8+
9+
let content = readFileSync(filePath, "utf-8");
10+
const title = content.split("\n")[0].substring(1).trim();
11+
if (title === "--") return;
12+
console.log(`Title: ${title}`);
13+
14+
content = `---
15+
title: "${title}"
16+
pubDate: "${lastWriteDate}"
17+
---
18+
${content}`;
19+
20+
writeFileSync(filePath, content);
21+
}
22+
23+
const blogsDir = "./src/content/blog";
24+
readdirSync(blogsDir).forEach((blog) => {
25+
const blogPath = join(blogsDir, blog);
26+
if (statSync(blogPath).isDirectory()) {
27+
readdirSync(blogPath).forEach((blogFile) => {
28+
const blogFilePath = join(blogPath, blogFile);
29+
if (statSync(blogFilePath).isFile()) {
30+
transform(blogFilePath);
31+
}
32+
});
33+
}
34+
});

.scripts/transform.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)