newsnow/server/sources/toutiao.ts

24 lines
483 B
TypeScript
Raw 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
}
}[]
}
export default defineSource(async () => {
const url = "https://www.toutiao.com/hot-event/hot-board/?origin=toutiao_pc"
const res: Res = await $fetch(url)
return res.data
.map((k) => {
return {
id: k.ClusterIdStr,
title: k.Title,
url: `https://www.toutiao.com/trending/${k.ClusterIdStr}/`,
}
})
})