feat(blog) add CMS, render blog posts list

- use GitHub repo as cms, read idx.json
- blog posts list
This commit is contained in:
lumither committed 2024-04-27 12:03:08 +08:00
1 parent 7419e7e3cf
commit 603dbf71a6
7 files changed
+98 -2

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
import { Result } from '@/app/public/type/Result';
export default async function fetch_posts(url: string): Promise<Result<JSON[], Error>> {
const response = await fetch(`${ url }/posts/idx.json`);
if (!response.ok) {
return {
ok: false,
error: new Error(response.statusText)
};
}
const res = await response.json();
const posts = res['idx'].filter((posts: { type: string }) => posts.type === 'md');
return {
ok: true,
value: posts
};
}