include drafts
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Michael Zhang 2023-08-31 09:05:06 -05:00
parent 86feeefbe3
commit 10426919e1
5 changed files with 46 additions and 8 deletions

View file

@ -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);
---

View file

@ -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.

13
src/pages/drafts.astro Normal file
View file

@ -0,0 +1,13 @@
---
import PostList from "../components/PostList.astro";
import BaseLayout from "../layouts/BaseLayout.astro";
import { join } from "path";
const currentUrl = Astro.url;
---
<BaseLayout>
<h2>Blog</h2>
<PostList basePath={join(currentUrl.pathname, "posts")} drafts="only" />
</BaseLayout>

View file

@ -9,7 +9,5 @@ const currentUrl = Astro.url;
<BaseLayout>
<h2>Blog</h2>
<!-- {JSON.stringify(allPosts)} -->
<PostList basePath={join(currentUrl.pathname, "posts")} />
</BaseLayout>

View file

@ -1,3 +0,0 @@
---
---