From 10426919e1892fbba2662596df96f3b234ce0ac4 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Thu, 31 Aug 2023 09:05:06 -0500 Subject: [PATCH] include drafts --- src/components/PostList.astro | 20 ++++++++++++++++--- .../posts/2023-08-31-thoughts-on-logseq.md | 16 +++++++++++++++ src/pages/drafts.astro | 13 ++++++++++++ src/pages/index.astro | 2 -- src/pages/posts/index.astro | 3 --- 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 src/content/posts/2023-08-31-thoughts-on-logseq.md create mode 100644 src/pages/drafts.astro delete mode 100644 src/pages/posts/index.astro diff --git a/src/components/PostList.astro b/src/components/PostList.astro index bca90e1..767d0cf 100644 --- a/src/components/PostList.astro +++ b/src/components/PostList.astro @@ -5,12 +5,26 @@ import { sortBy } from "lodash-es"; interface Props { basePath: string; - includeDrafts?: boolean; + drafts?: "exclude" | "include" | "only"; } type Post = CollectionEntry<"posts">; -const { basePath, includeDrafts } = Astro.props; -const filter = includeDrafts ? (_: Post) => true : (post: Post) => !post.data.draft; +const { basePath, drafts: includeDrafts } = Astro.props; + +let filter; +switch (includeDrafts) { + case "exclude": + case undefined: + filter = (post: Post) => !post.data.draft; + break; + case "include": + filter = (_: Post) => true; + break; + case "only": + filter = (post: Post) => post.data.draft === true; + break; +} + const allPosts = await getCollection("posts", filter); const sortedPosts = sortBy(allPosts, (post) => -post.data.date); --- diff --git a/src/content/posts/2023-08-31-thoughts-on-logseq.md b/src/content/posts/2023-08-31-thoughts-on-logseq.md new file mode 100644 index 0000000..44c0fcc --- /dev/null +++ b/src/content/posts/2023-08-31-thoughts-on-logseq.md @@ -0,0 +1,16 @@ +--- +title: Thoughts on Logseq +date: 2023-08-31T13:57:29.022Z +tags: + - organization + - logseq +draft: true +--- + +After working for quite a bit I like to catch up with some friends from time to +time, when I made a shocking discovery -- most of them don't really use a +calendar of any sort to manage their lives. + +For a while I've always wanted a kind of personal information manager: something +that would put all my information in one place and make it easy for me to query +across apps. diff --git a/src/pages/drafts.astro b/src/pages/drafts.astro new file mode 100644 index 0000000..fe0b713 --- /dev/null +++ b/src/pages/drafts.astro @@ -0,0 +1,13 @@ +--- +import PostList from "../components/PostList.astro"; +import BaseLayout from "../layouts/BaseLayout.astro"; +import { join } from "path"; + +const currentUrl = Astro.url; +--- + + +

Blog

+ + +
diff --git a/src/pages/index.astro b/src/pages/index.astro index a8cd3d2..9a01b71 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -9,7 +9,5 @@ const currentUrl = Astro.url;

Blog

- -
diff --git a/src/pages/posts/index.astro b/src/pages/posts/index.astro deleted file mode 100644 index 853d812..0000000 --- a/src/pages/posts/index.astro +++ /dev/null @@ -1,3 +0,0 @@ ---- - ----