添加博客头图
This commit is contained in:
@ -24,6 +24,10 @@ export type ListBlogItemType = {
|
||||
}
|
||||
}
|
||||
|
||||
export type BlogContentType = ListBlogItemType & {
|
||||
content: string
|
||||
}
|
||||
|
||||
export const listBlogs = async ({
|
||||
page = 1,
|
||||
limit = 20,
|
||||
@ -58,17 +62,30 @@ export const listBlogs = async ({
|
||||
|
||||
export const getBlog: (
|
||||
blog_id: number,
|
||||
) => Promise<null | { title: string; content: string }> = async (
|
||||
blog_id: number,
|
||||
) => {
|
||||
) => Promise<null | BlogContentType> = async (blog_id: number) => {
|
||||
const resp = await legacyClient.get(`/v1/blog/${blog_id}`, {
|
||||
validateStatus: (status) => status == 200 || status == 404,
|
||||
})
|
||||
if (resp.status == 404) {
|
||||
return null
|
||||
}
|
||||
return resp.data as {
|
||||
title: string
|
||||
content: string
|
||||
let _blog = resp.data
|
||||
|
||||
if (_blog.featured_image) {
|
||||
_blog = {
|
||||
..._blog,
|
||||
featured_image: {
|
||||
image_url:
|
||||
'https://legacy.passthem.top' + _blog.featured_image.image_url,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
_blog.author.avatar = {
|
||||
image_url: 'https://legacy.passthem.top' + _blog.author.avatar.image_url,
|
||||
}
|
||||
_blog.created_at = new Date(_blog.created_at)
|
||||
_blog.updated_at = new Date(_blog.updated_at)
|
||||
|
||||
return _blog
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user