完成BlogApi
This commit is contained in:
11
tone-page-web/lib/api/blog/get.ts
Normal file
11
tone-page-web/lib/api/blog/get.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function get(id: string) {
|
||||
return fetcher<{
|
||||
id: string;
|
||||
title: string;
|
||||
createdAt: string;
|
||||
content: string;
|
||||
}>(`/api/blog/${id}`);
|
||||
}
|
||||
2
tone-page-web/lib/api/blog/index.ts
Normal file
2
tone-page-web/lib/api/blog/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './list';
|
||||
export * from './get';
|
||||
6
tone-page-web/lib/api/blog/list.ts
Normal file
6
tone-page-web/lib/api/blog/list.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function list() {
|
||||
return fetcher<Blog[]>('/api/blog');
|
||||
}
|
||||
@@ -2,4 +2,5 @@ export * as authApi from './auth/index';
|
||||
export * as verificationApi from './verification/index';
|
||||
export * as AdminApi from './admin/index';
|
||||
export * as ResourceApi from './resource/index';
|
||||
export * as BlogApi from './blog/index';
|
||||
export * as UserApi from './user/index';
|
||||
@@ -2,5 +2,7 @@ export interface Blog {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
viewCount: number;
|
||||
contentUrl: string;
|
||||
createdAt: string;
|
||||
}
|
||||
Reference in New Issue
Block a user