mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
feat: source add zhihu
This commit is contained in:
parent
1856f07a48
commit
707dae5af1
@ -3,6 +3,7 @@ import weibo from "./weibo"
|
||||
import zaobao from "./zaobao"
|
||||
import v2ex from "./v2ex"
|
||||
import ithome from "./ithome"
|
||||
import zhihu from "./zhihu"
|
||||
|
||||
export const sourcesFn = {
|
||||
weibo,
|
||||
@ -12,6 +13,7 @@ export const sourcesFn = {
|
||||
"peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", {
|
||||
hiddenDate: true,
|
||||
}),
|
||||
"zhihu": zhihu,
|
||||
"sputniknewscn": defineRSSHubSource("/sputniknews/news/chinese"),
|
||||
"douyin": defineFallbackSource("douyin"),
|
||||
"aljazeeracn": defineRSSSource("https://feedx.net/rss/aljazeera.xml"),
|
||||
|
38
server/sources/zhihu.ts
Normal file
38
server/sources/zhihu.ts
Normal file
@ -0,0 +1,38 @@
|
||||
interface Res {
|
||||
data: {
|
||||
card_label?: {
|
||||
icon: string
|
||||
night_icon: string
|
||||
}
|
||||
target: {
|
||||
id: number
|
||||
title: string
|
||||
url: string
|
||||
created: number
|
||||
answer_count: number
|
||||
follower_count: number
|
||||
bound_topic_ids: number[]
|
||||
comment_count: number
|
||||
is_following: boolean
|
||||
excerpt: string
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
export default defineSource(async () => {
|
||||
const url = "https://www.zhihu.com/api/v3/feed/topstory/hot-lists/total?limit=20&desktop=true"
|
||||
const res: Res = await $fetch(url)
|
||||
if (!res.data || res.data.length === 0) throw new Error("Cannot fetch data")
|
||||
return res.data
|
||||
.slice(0, 20)
|
||||
.map((k) => {
|
||||
return {
|
||||
id: k.target.id,
|
||||
title: k.target.title,
|
||||
extra: {
|
||||
icon: k.card_label?.night_icon,
|
||||
},
|
||||
url: `https://www.zhihu.com/question/${k.target.id}`,
|
||||
}
|
||||
})
|
||||
})
|
@ -9,11 +9,11 @@ export const metadata: Metadata = {
|
||||
},
|
||||
social: {
|
||||
name: "实时",
|
||||
sources: ["douyin", "weibo", "wallstreetcn", "ithome", "36kr"],
|
||||
sources: ["weibo", "douyin", "zhihu", "toutiao", "wallstreetcn", "ithome", "36kr"],
|
||||
},
|
||||
china: {
|
||||
name: "国内",
|
||||
sources: ["peopledaily", "toutiao"],
|
||||
sources: ["peopledaily", "toutiao", "zhihu"],
|
||||
},
|
||||
world: {
|
||||
name: "国外",
|
||||
|
@ -13,6 +13,7 @@ export const originSources = {
|
||||
},
|
||||
"sputniknewscn": {
|
||||
name: "俄罗斯卫星通讯社",
|
||||
interval: 30 * 60 * 1000,
|
||||
home: "https://sputniknews.cn",
|
||||
},
|
||||
"aljazeeracn": {
|
||||
@ -57,6 +58,7 @@ export const originSources = {
|
||||
},
|
||||
"thepaper": {
|
||||
name: "澎湃新闻",
|
||||
interval: 30 * 60 * 1000,
|
||||
home: "https://www.thepaper.cn",
|
||||
},
|
||||
"toutiao": {
|
||||
@ -65,11 +67,11 @@ export const originSources = {
|
||||
},
|
||||
"cankaoxiaoxi": {
|
||||
name: "参考消息",
|
||||
interval: 60 * 60 * 1000,
|
||||
home: "http://www.cankaoxiaoxi.com",
|
||||
},
|
||||
"ithome": {
|
||||
name: "IT之家",
|
||||
interval: 1000,
|
||||
home: "https://www.ithome.com",
|
||||
},
|
||||
"peopledaily": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user