mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
fix(route): fix GitHub route parameter conflict at trending.js and refactor to V2 (#8923)
* Fix(route): fix route parameter conflict at trending.js and change to V2 * Fix(route): modify the judgment condition of language parameter * Fix(docs): Update docs/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(docs): Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(docs/route): add author and sort routes * Fix(route): Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Fix(route): sort routes Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
25
lib/v2/github/topic.js
Normal file
25
lib/v2/github/topic.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://github.com/topics/${ctx.params.name}?${ctx.params.qs}`;
|
||||
const { data } = await got(link);
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link,
|
||||
item: $('article.my-4')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
const title = $(item.find('h1 a').get(1)).attr('href').slice(1);
|
||||
const author = title.split('/')[0];
|
||||
const description = item.find('div.border-bottom > div > p + div').text();
|
||||
const link = `https://github.com/${title}`;
|
||||
|
||||
return { title, author, description, link };
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user