Update route.ts
This commit is contained in:
1 parent
865d9ec984
commit
c57fbb1d7b
1 file changed
+18
-8
@@ -118,14 +118,24 @@ export async function POST(request: NextRequest) {
|
|||||||
const rawContent = (a.content as string) || "";
|
const rawContent = (a.content as string) || "";
|
||||||
const { html, imageUrls } = mdToWechatHtml(rawContent, slug);
|
const { html, imageUrls } = mdToWechatHtml(rawContent, slug);
|
||||||
|
|
||||||
const result: Record<string, unknown> = {
|
const result: {
|
||||||
title: a.title,
|
title: string;
|
||||||
author: a.author,
|
author: string;
|
||||||
|
content: string;
|
||||||
|
content_source_url?: string;
|
||||||
|
thumb_media_url?: string;
|
||||||
|
thumb_media_id?: string;
|
||||||
|
show_cover_pic: number;
|
||||||
|
need_open_comment: number;
|
||||||
|
content_image_urls?: { original_url: string }[];
|
||||||
|
} = {
|
||||||
|
title: String(a.title || ""),
|
||||||
|
author: String(a.author || ""),
|
||||||
content: html,
|
content: html,
|
||||||
content_source_url: a.content_source_url,
|
content_source_url: a.content_source_url as string | undefined,
|
||||||
thumb_media_url: a.thumb_media_url,
|
thumb_media_url: a.thumb_media_url as string | undefined,
|
||||||
show_cover_pic: a.show_cover_pic ?? 1,
|
show_cover_pic: (a.show_cover_pic as number) ?? 1,
|
||||||
need_open_comment: a.need_open_comment ?? 0,
|
need_open_comment: (a.need_open_comment as number) ?? 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (imageUrls.length > 0) {
|
if (imageUrls.length > 0) {
|
||||||
@@ -135,7 +145,7 @@ export async function POST(request: NextRequest) {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await syncWechat(processedArticles);
|
const result = await syncWechat(processedArticles as any);
|
||||||
return NextResponse.json(result);
|
return NextResponse.json(result);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const msg = error instanceof Error ? error.message : "Unknown error";
|
const msg = error instanceof Error ? error.message : "Unknown error";
|
||||||
|
|||||||
Reference in new issue
Block a user