chore: add kaopu.news

This commit is contained in:
Ou 2024-10-25 22:08:02 +08:00
parent 7351d1ed9f
commit 392a24c817
6 changed files with 36 additions and 3 deletions

BIN
public/icons/kaopu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

1
server/glob.d.ts vendored
View File

@ -12,6 +12,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' {
export const github: typeof import('./sources/github')
export const hackernews: typeof import('./sources/hackernews')
export const ithome: typeof import('./sources/ithome')
export const kaopu: typeof import('./sources/kaopu')
export const producthunt: typeof import('./sources/producthunt')
export const solidot: typeof import('./sources/solidot')
export const sputniknewscn: typeof import('./sources/sputniknewscn')

27
server/sources/kaopu.ts Normal file
View File

@ -0,0 +1,27 @@
type Res = {
description: string
link: string
// Date
pubDate: string
publisher: string
title: string
}[]
export default defineSource(async () => {
const url = "https://kaopucdn.azureedge.net/jsondata/news_list_beta_hans_0.json"
const res: Res = await $fetch(url)
return res
.slice(0, 30)
.map((k) => {
return {
id: k.link,
title: k.title,
pubDate: k.pubDate,
extra: {
hover: k.description,
info: k.publisher,
},
url: k.link,
}
})
},
)

View File

@ -7,11 +7,11 @@ export const columnIds = ["focus", "realtime", "hottest", "china", "world", "tec
const originMetadata: Metadata = {
china: {
name: "国内",
sources: ["zhihu", "thepaper"],
sources: ["zhihu", "thepaper", "douyin", "bilibili-hot-search", "weibo", "toutiao", "tieba"],
},
world: {
name: "国际",
sources: ["zaobao", "cankaoxiaoxi"],
sources: ["zaobao", "cankaoxiaoxi", "kaopu"],
},
tech: {
name: "科技",

View File

@ -225,6 +225,11 @@ export const originSources = {
},
},
},
"kaopu": {
name: "靠谱新闻",
color: "gray",
home: "https://kaopu.news/",
},
} as const satisfies Record<string, OriginSource>
export const sources = genSources()

View File

@ -143,7 +143,7 @@ function NewsCard({ id, inView, handleListeners }: NewsCardProps) {
defer
>
<div className={clsx("transition-opacity-500", isFreshFetching && "op-20")}>
{data?.items?.length && (sources[id].type === "hottest" ? <NewsListHot items={data.items} /> : <NewsListTimeLine items={data.items} />)}
{!!data?.items?.length && (sources[id].type === "hottest" ? <NewsListHot items={data.items} /> : <NewsListTimeLine items={data.items} />)}
</div>
</OverlayScrollbar>
</>