fix(route/huggingface): fix getting blog links and community blog author data handling. (#20644)

* fix(route/huggingface): fix getting blog links and community blog author data handling.

* fix(route/huggingface): fix property error.
This commit is contained in:
Jinghao Tu 2025-12-06 01:04:10 +08:00 committed by GitHub
parent 601ce1a72e
commit 7196256dcd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -54,7 +54,7 @@ interface AuthorData {
interface Post {
_id: string;
authorData: AuthorData;
authorsData: AuthorData[];
canonical: boolean;
isUpvotedByUser: boolean;
numCoauthors: number;
@ -64,6 +64,7 @@ interface Post {
title: string;
upvotes: number;
thumbnail?: string;
url: string;
}
interface CommunityBlogApiResponse {
@ -83,9 +84,9 @@ async function handler(ctx) {
const lists = posts.map((item) => ({
title: item.title,
link: `https://huggingface.co/blog/${item.authorData.name}/${item.slug}`,
link: `https://huggingface.co${item.url}`,
pubDate: parseDate(item.publishedAt),
author: item.authorData.fullname || item.authorData.name,
author: item.authorsData?.[0]?.fullname || item.authorsData?.[0]?.name || 'Unknown',
upvotes: item.upvotes,
image: item.thumbnail ? new URL(item.thumbnail, 'https://huggingface.co').toString() : undefined,
}));

View File

@ -18,6 +18,7 @@ interface BlogItem {
upvotes: number;
thumbnail: string;
tags: string[];
url: string;
}
interface BlogApiResponse {
@ -55,7 +56,7 @@ async function handler() {
const lists = allBlogs.map((blog) => ({
title: blog.title,
link: `https://huggingface.co/blog/${blog.slug}`,
link: `https://huggingface.co${blog.url}`,
pubDate: parseDate(blog.publishedAt),
author: blog.authorsData.map((author) => ({
name: author.fullname || author.name,