mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 11:19: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 zaobao from "./zaobao"
|
||||||
import v2ex from "./v2ex"
|
import v2ex from "./v2ex"
|
||||||
import ithome from "./ithome"
|
import ithome from "./ithome"
|
||||||
|
import zhihu from "./zhihu"
|
||||||
|
|
||||||
export const sourcesFn = {
|
export const sourcesFn = {
|
||||||
weibo,
|
weibo,
|
||||||
@ -12,6 +13,7 @@ export const sourcesFn = {
|
|||||||
"peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", {
|
"peopledaily": defineRSSSource("https://feedx.net/rss/people.xml", {
|
||||||
hiddenDate: true,
|
hiddenDate: true,
|
||||||
}),
|
}),
|
||||||
|
"zhihu": zhihu,
|
||||||
"sputniknewscn": defineRSSHubSource("/sputniknews/news/chinese"),
|
"sputniknewscn": defineRSSHubSource("/sputniknews/news/chinese"),
|
||||||
"douyin": defineFallbackSource("douyin"),
|
"douyin": defineFallbackSource("douyin"),
|
||||||
"aljazeeracn": defineRSSSource("https://feedx.net/rss/aljazeera.xml"),
|
"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: {
|
social: {
|
||||||
name: "实时",
|
name: "实时",
|
||||||
sources: ["douyin", "weibo", "wallstreetcn", "ithome", "36kr"],
|
sources: ["weibo", "douyin", "zhihu", "toutiao", "wallstreetcn", "ithome", "36kr"],
|
||||||
},
|
},
|
||||||
china: {
|
china: {
|
||||||
name: "国内",
|
name: "国内",
|
||||||
sources: ["peopledaily", "toutiao"],
|
sources: ["peopledaily", "toutiao", "zhihu"],
|
||||||
},
|
},
|
||||||
world: {
|
world: {
|
||||||
name: "国外",
|
name: "国外",
|
||||||
|
@ -13,6 +13,7 @@ export const originSources = {
|
|||||||
},
|
},
|
||||||
"sputniknewscn": {
|
"sputniknewscn": {
|
||||||
name: "俄罗斯卫星通讯社",
|
name: "俄罗斯卫星通讯社",
|
||||||
|
interval: 30 * 60 * 1000,
|
||||||
home: "https://sputniknews.cn",
|
home: "https://sputniknews.cn",
|
||||||
},
|
},
|
||||||
"aljazeeracn": {
|
"aljazeeracn": {
|
||||||
@ -57,6 +58,7 @@ export const originSources = {
|
|||||||
},
|
},
|
||||||
"thepaper": {
|
"thepaper": {
|
||||||
name: "澎湃新闻",
|
name: "澎湃新闻",
|
||||||
|
interval: 30 * 60 * 1000,
|
||||||
home: "https://www.thepaper.cn",
|
home: "https://www.thepaper.cn",
|
||||||
},
|
},
|
||||||
"toutiao": {
|
"toutiao": {
|
||||||
@ -65,11 +67,11 @@ export const originSources = {
|
|||||||
},
|
},
|
||||||
"cankaoxiaoxi": {
|
"cankaoxiaoxi": {
|
||||||
name: "参考消息",
|
name: "参考消息",
|
||||||
|
interval: 60 * 60 * 1000,
|
||||||
home: "http://www.cankaoxiaoxi.com",
|
home: "http://www.cankaoxiaoxi.com",
|
||||||
},
|
},
|
||||||
"ithome": {
|
"ithome": {
|
||||||
name: "IT之家",
|
name: "IT之家",
|
||||||
interval: 1000,
|
|
||||||
home: "https://www.ithome.com",
|
home: "https://www.ithome.com",
|
||||||
},
|
},
|
||||||
"peopledaily": {
|
"peopledaily": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user