mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
feat(route): add Apache APISIX 博客 & 云原生社区博客 & 支流科技博客 (#12294)
* Add apiseven blog * Add apache apisix blog * Add cloudnative blog * Add radar.js and docs * Fix code styles * Fix code styles * Use `markdown-it` to render the description
This commit is contained in:
34
lib/v2/cloudnative/blog.js
Normal file
34
lib/v2/cloudnative/blog.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
async function getArticles() {
|
||||
const url = 'https://cloudnative.to/blog/';
|
||||
const { data: res } = await got(url);
|
||||
const $ = cheerio.load(res);
|
||||
const articles = $('div.page-body .stream-item');
|
||||
return articles.toArray().map((elem) => {
|
||||
const a = $(elem).find('.article-title > a');
|
||||
const summary = $(elem).find('.summary-link');
|
||||
const meta = $(elem).find('.stream-meta .article-metadata');
|
||||
const time = meta.find('.article-date').text().replace('发布于', '');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: a.attr('href'),
|
||||
description: summary.text(),
|
||||
pubDate: timezone(parseDate(time, 'YYYY-MM-DD'), +8),
|
||||
author: meta.find('span').eq(0).find('a').text(),
|
||||
category: meta.find('.article-categories a').text(),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const articles = await getArticles();
|
||||
ctx.state.data = {
|
||||
title: '博客 | 云原生社区(中国)',
|
||||
link: 'https://cloudnative.to/blog/',
|
||||
item: articles,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user