feat: 调整博客页以支持slug

This commit is contained in:
2025-12-27 13:48:48 +08:00
parent b9d09a16ec
commit b48ed4d903
5 changed files with 29 additions and 30 deletions

View File

@@ -3,16 +3,17 @@ import { serverFetch } from "../server";
export async function list() {
return serverFetch<Pick<Blog,
'id' | 'title' | 'description' | 'viewCount' | 'createdAt' | 'updatedAt' | 'deletedAt'
'id' | 'title' | 'slug' | 'description' | 'viewCount' | 'createdAt' | 'updatedAt' | 'deletedAt'
>[]>('/api/blog')
}
export async function getBlog(id: string, password?: string) {
export async function getBlogBySlug(slug: string, password?: string) {
return serverFetch<{
id: string;
title: string;
description: string;
createdAt: string;
content: string;
}>(`/api/blog/${id}` + (password ? `?p=${password}` : ''));
}
}>(`/api/blog/${slug}/slug` + (password ? `?p=${password}` : ''));
}