mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
feat(blog) add CMS, render blog posts list
- use GitHub repo as cms, read idx.json - blog posts list
This commit is contained in:
7 files changed
+98
-2
No files matched your search
@@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user