2024-10-30 15:59:59 +08:00

30 lines
617 B
TypeScript

interface Res {
data: {
cards: {
content: {
isTop?: boolean
word: string
rawUrl: string
desc?: string
}[]
}[]
}
}
export default defineSource(async () => {
const rawData: string = await myFetch(`https://top.baidu.com/board?tab=realtime`)
const jsonStr = (rawData as string).match(/<!--s-data:(.*?)-->/s)
const data: Res = JSON.parse(jsonStr![1])
return data.data.cards[0].content.filter(k => !k.isTop).map((k) => {
return {
id: k.rawUrl,
title: k.word,
url: k.rawUrl,
extra: {
hover: k.desc,
},
}
})
})