feat(route/chub): support markdown and move thumbnail image to description (#21184)

* Update api url

* remove trailing '

* feat(route/chub): support markdown and move thumbnail image to description

* style: auto format

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
flameleaf 2026-02-20 13:34:53 -08:00 committed by GitHub
parent 0b056eba75
commit 12e5f3ef71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 3 deletions

View File

@ -1,7 +1,16 @@
import MarkdownIt from 'markdown-it';
import type { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
const md = MarkdownIt({
breaks: true,
html: true,
linkify: true,
typographer: true,
});
export const route: Route = {
path: '/characters',
categories: ['new-media'],
@ -14,6 +23,10 @@ export const route: Route = {
},
};
function convertUndefinedToString(value: any): string {
return value === undefined ? '' : value.toString();
}
async function handler() {
const hostURL = 'https://www.chub.ai/characters';
const apiURL = 'https://api.chub.ai/search';
@ -52,13 +65,13 @@ async function handler() {
link: hostURL,
item: nodes.map((item) => ({
title: item.name,
description: `${item.tagline}<br><br>${item.description}`,
description: `<div><img src="${item.avatar_url}" /></div><div>${item.tagline}</div><div>${md.render(convertUndefinedToString(item.description))}</div>`,
pubDate: parseDate(item.createdAt),
updated: parseDate(item.lastActivityAt),
link: `${hostURL}/${item.fullPath}`,
author: String(item.fullPath.split('/', 1)),
enclosure_url: item.avatar_url,
enclosure_type: `image/webp`,
enclosure_url: item.max_res_url,
enclosure_type: `image/png`,
category: item.topics,
})),
};