diff --git a/lib/v2/howtoforge/maintainer.js b/lib/v2/howtoforge/maintainer.js new file mode 100644 index 000000000..387d961bf --- /dev/null +++ b/lib/v2/howtoforge/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/v2/howtoforge/radar.js b/lib/v2/howtoforge/radar.js new file mode 100644 index 000000000..fb531123b --- /dev/null +++ b/lib/v2/howtoforge/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'howtoforge.com': { + _name: "Howtoforge Linux Tutorials", + '.': [ + { + title: '学习', + docs: 'https://docs.rsshub.app/routes/study#howtoforge-linux-tutorials', + source: ['/'], + target: '/howtoforge', + }, + ], + }, +}; diff --git a/lib/v2/howtoforge/router.js b/lib/v2/howtoforge/router.js new file mode 100644 index 000000000..574929e02 --- /dev/null +++ b/lib/v2/howtoforge/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./rss')); +}; diff --git a/lib/v2/howtoforge/rss.js b/lib/v2/howtoforge/rss.js new file mode 100644 index 000000000..74ffa6860 --- /dev/null +++ b/lib/v2/howtoforge/rss.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const currentUrl = 'https://www.howtoforge.com'; + const response = await got(`${currentUrl}/feed.rss`); + const $ = cheerio.load(response.data, { xmlMode: true }); + const titleMain = $('channel > title').text(); + const descriptionMain = $('channel > description').text(); + const items = $('channel > item') + .map((_, item) => { + const $item = $(item); + const link = $item.find('link').text(); + const title = $item.find('title').text(); + const description = $item.find('description').text(); + const pubDate = $item.find('pubDate').text(); + return { + link, + pubDate, // no need to normalize because it's from a valid RSS feed + title, + description, + }; + }) + .get(); + + ctx.state.data = { + title: titleMain, + description: descriptionMain, + link: currentUrl, + item: items, + }; +}; diff --git a/website/docs/routes/study.mdx b/website/docs/routes/study.mdx index 587ae3e68..3c4873d1c 100644 --- a/website/docs/routes/study.mdx +++ b/website/docs/routes/study.mdx @@ -689,3 +689,9 @@ | 新疆维吾尔自治区 | 65 | | 台湾 | 71 | + +## Howtoforge Linux Tutorials {#Howtoforge-Linux-Tutorials} + +### tutorials {#Howtoforge-Linux-Tutorials-all} + +