This commit is contained in:
parent
86feeefbe3
commit
10426919e1
5 changed files with 46 additions and 8 deletions
|
@ -5,12 +5,26 @@ import { sortBy } from "lodash-es";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
basePath: string;
|
basePath: string;
|
||||||
includeDrafts?: boolean;
|
drafts?: "exclude" | "include" | "only";
|
||||||
}
|
}
|
||||||
|
|
||||||
type Post = CollectionEntry<"posts">;
|
type Post = CollectionEntry<"posts">;
|
||||||
const { basePath, includeDrafts } = Astro.props;
|
const { basePath, drafts: includeDrafts } = Astro.props;
|
||||||
const filter = includeDrafts ? (_: Post) => true : (post: Post) => !post.data.draft;
|
|
||||||
|
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 allPosts = await getCollection("posts", filter);
|
||||||
const sortedPosts = sortBy(allPosts, (post) => -post.data.date);
|
const sortedPosts = sortBy(allPosts, (post) => -post.data.date);
|
||||||
---
|
---
|
||||||
|
|
16
src/content/posts/2023-08-31-thoughts-on-logseq.md
Normal file
16
src/content/posts/2023-08-31-thoughts-on-logseq.md
Normal 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
13
src/pages/drafts.astro
Normal 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>
|
|
@ -9,7 +9,5 @@ const currentUrl = Astro.url;
|
||||||
<BaseLayout>
|
<BaseLayout>
|
||||||
<h2>Blog</h2>
|
<h2>Blog</h2>
|
||||||
|
|
||||||
<!-- {JSON.stringify(allPosts)} -->
|
|
||||||
|
|
||||||
<PostList basePath={join(currentUrl.pathname, "posts")} />
|
<PostList basePath={join(currentUrl.pathname, "posts")} />
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
---
|
|
Loading…
Reference in a new issue