newsnow/server/sources/toutiao.ts

30 lines
637 B
TypeScript
Raw Permalink Normal View History

2024-10-13 11:39:28 +08:00
interface Res {
2024-10-21 01:38:58 +08:00
data: {
2024-10-13 11:39:28 +08:00
ClusterIdStr: string
Title: string
HotValue: string
Image: {
url: string
}
2024-10-31 14:21:11 +08:00
LabelUri?: {
url: string
}
2024-10-13 11:39:28 +08:00
}[]
}
export default defineSource(async () => {
const url = "https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc"
const res: Res = await myFetch(url)
2024-10-13 11:39:28 +08:00
return res.data
.map((k) => {
return {
id: k.ClusterIdStr,
title: k.Title,
url: `https://www.toutiao.com/trending/${k.ClusterIdStr}/`,
2024-10-31 14:21:11 +08:00
extra: {
2024-11-01 19:46:37 +08:00
icon: k.LabelUri?.url && proxyPicture(k.LabelUri.url, "encodeBase64URL"),
2024-10-31 14:21:11 +08:00
},
2024-10-13 11:39:28 +08:00
}
})
})