forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: V2EX Route Exclude Duplicate Posts (DIYgod#13144)
* update: V2EX Route Exclude Duplicate Posts * use ctx.query.limit * refactor: migrate to v2 --------- Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
- Loading branch information
1 parent
966e812
commit 9335585
Showing
8 changed files
with
101 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
'/post/:postid': ['kt286'], | ||
'/tab/:tabid': ['liyefox'], | ||
'/topics/:type': ['WhiteWorld'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const got = require('@/utils/got'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { postid } = ctx.params; | ||
const pageUrl = `https://www.v2ex.com/t/${postid}`; | ||
|
||
const { data: topicResponse } = await got('https://www.v2ex.com/api/topics/show.json', { | ||
searchParams: { | ||
id: postid, | ||
}, | ||
}); | ||
|
||
const { data: replies } = await got('https://www.v2ex.com/api/replies/show.json', { | ||
searchParams: { | ||
topic_id: postid, | ||
}, | ||
}); | ||
|
||
const topic = topicResponse[0]; | ||
|
||
ctx.state.data = { | ||
title: `V2EX-${topic.title}`, | ||
link: pageUrl, | ||
description: topic.content, | ||
item: replies.map((item, index) => ({ | ||
title: `#${index + 1} ${item.content}`, | ||
description: item.content_rendered, | ||
link: `${pageUrl}#r_${item.id}`, | ||
author: item.member.username, | ||
pubDate: parseDate(item.created, 'X'), | ||
})), | ||
allowEmpty: true, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module.exports = { | ||
'v2ex.com': { | ||
_name: 'V2EX', | ||
'.': [ | ||
{ | ||
title: '最热 / 最新主题', | ||
docs: 'https://docs.rsshub.app/routes/v2ex', | ||
source: ['/'], | ||
target: (_, url) => { | ||
const { searchParams } = new URL(url); | ||
if (searchParams.get('tab') === 'all' || searchParams.get('tab') === 'hot') { | ||
return `/v2ex/topics/${searchParams.get('tab')?.replace('all', 'latest')}`; | ||
} | ||
}, | ||
}, | ||
{ | ||
title: '帖子', | ||
docs: 'https://docs.rsshub.app/routes/v2ex', | ||
source: ['/t/:postid'], | ||
target: '/v2ex/post/:postid', | ||
}, | ||
{ | ||
title: '标签', | ||
docs: 'https://docs.rsshub.app/routes/v2ex', | ||
source: ['/'], | ||
target: (_, url) => { | ||
const { searchParams } = new URL(url); | ||
if (searchParams.get('tab') && searchParams.get('tab') !== 'all' && searchParams.get('tab') !== 'hot') { | ||
return `/v2ex/tab/${searchParams.get('tab')}`; | ||
} | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = (router) => { | ||
router.get('/post/:postid', require('./post')); | ||
router.get('/tab/:tabid', require('./tab')); | ||
router.get('/topics/:type', require('./topics')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters