This commit is contained in:
parent
a9ac9d3eac
commit
1f1d0b66da
2 changed files with 12 additions and 4 deletions
14
index.ts
14
index.ts
|
|
@ -26,6 +26,7 @@ const defaultFrontmatter = {
|
||||||
desc: "",
|
desc: "",
|
||||||
date: "0000-00-00", // YYYY-MM-DD
|
date: "0000-00-00", // YYYY-MM-DD
|
||||||
draft: true,
|
draft: true,
|
||||||
|
skip: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
function fetchFrontmatter(raw?: string) {
|
function fetchFrontmatter(raw?: string) {
|
||||||
|
|
@ -40,10 +41,17 @@ function fetchFrontmatter(raw?: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(posts.map(async (post) => {
|
await Promise.all(posts.map(async (post) => {
|
||||||
const raw = (await Bun.file(`./posts/${post}`).text()).split("^---");
|
if (!post.endsWith(".md")) return;
|
||||||
|
const raw = await Bun.file(`./posts/${post}`).text();
|
||||||
|
const lines = raw.split("\n");
|
||||||
|
|
||||||
const content = raw.at(-1) || "_No content_";
|
const closingIndex = lines[0] === "---" ? lines.indexOf("---", 1) : -1;
|
||||||
const frontmatter = fetchFrontmatter(raw.at(0));
|
const frontmatterRaw = closingIndex > 0 ? lines.slice(1, closingIndex).join("\n") : undefined;
|
||||||
|
const contentRaw = closingIndex > 0 ? lines.slice(closingIndex + 1).join("\n") : raw;
|
||||||
|
|
||||||
|
const frontmatter = fetchFrontmatter(frontmatterRaw);
|
||||||
|
if (frontmatter.skip) return;
|
||||||
|
const content = contentRaw || "_No content_";
|
||||||
|
|
||||||
const html = Bun.markdown.html(content, {
|
const html = Bun.markdown.html(content, {
|
||||||
autolinks: true,
|
autolinks: true,
|
||||||
|
|
|
||||||
2
posts
2
posts
|
|
@ -1 +1 @@
|
||||||
Subproject commit a6bc30e4abc671595fd847cb64931373f09bcd4b
|
Subproject commit 6ddb36d446ca999d389a8c9578bd5b0c56ec3472
|
||||||
Loading…
Reference in a new issue