fix(website): respect draft frontmatter field when filtering posts
Posts with `draft: true` in frontmatter were shown because isDraft only checked the file path for `/drafts/`. Now checks both path and frontmatter.
This commit is contained in:
@@ -40,10 +40,10 @@ function loadPosts(includeDrafts: boolean): Post[] {
|
||||
const posts: Post[] = [];
|
||||
|
||||
for (const [path, raw] of Object.entries(postModules)) {
|
||||
const isDraft = path.includes("/drafts/");
|
||||
const { data, content } = parseFrontmatter(raw);
|
||||
const isDraft = path.includes("/drafts/") || data.draft === "true";
|
||||
if (isDraft && !includeDrafts) continue;
|
||||
|
||||
const { data, content } = parseFrontmatter(raw);
|
||||
const fileName = path.split("/").pop()!.replace(".md", "");
|
||||
const slug = isDraft ? `drafts/${fileName}` : fileName;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user