feat(reader) add reader

This commit is contained in:
lumither committed 2024-04-30 00:40:59 +08:00
1 parent 603dbf71a6
commit a685537499
7 files changed
+76 -11

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_list(): Promise<Result<JSON[], Error>> {
const response = await fetch(`${ process.env.BLOG_ENDPOINT }/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
};
}