Skip to content

Commit

Permalink
private記事のバグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kgtkr committed Sep 12, 2022
1 parent d0f1915 commit 859759d
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions lib/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,23 @@ export function getAllPosts({
}: {
includePrivate?: boolean;
}): Post[] {
if (allPosts !== null) {
return allPosts;
if (allPosts === null) {
const keys = postContext.keys().filter((x) => x.endsWith(".md"));
allPosts = pipe(
keys,
A.map((key) => {
const { data, content } = matter(postContext(key).default);
return {
matter: Matter.parse(data),
markdown: content,
basedir: path.dirname(key),
};
}),
A.sort(PostOrd),
);
}

const keys = postContext.keys().filter((x) => x.endsWith(".md"));
allPosts = pipe(
keys,
A.map((key) => {
const { data, content } = matter(postContext(key).default);
return {
matter: Matter.parse(data),
markdown: content,
basedir: path.dirname(key),
};
}),
A.filter((post) => includePrivate || !post.matter.private),
A.sort(PostOrd),
);

return allPosts;
return allPosts.filter((post) => includePrivate || !post.matter.private);
}

export type Tag = {
Expand Down

0 comments on commit 859759d

Please sign in to comment.