From 859759d2e50641a8f30982815ad4971311db6da3 Mon Sep 17 00:00:00 2001
From: kgtkr <contact@kgtkr.net>
Date: Mon, 12 Sep 2022 22:01:19 +0900
Subject: [PATCH] =?UTF-8?q?private=E8=A8=98=E4=BA=8B=E3=81=AE=E3=83=90?=
 =?UTF-8?q?=E3=82=B0=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/blog.tsx | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/lib/blog.tsx b/lib/blog.tsx
index 17a0ba0..c196134 100644
--- a/lib/blog.tsx
+++ b/lib/blog.tsx
@@ -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 = {