mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 17:48:15 +08:00
* 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
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
async function getArticles() {
|
|
const url = 'https://apisix.apache.org/zh/blog/';
|
|
const { data: res } = await got(url);
|
|
const $ = cheerio.load(res);
|
|
const articles = $('section.sec_gjjg').eq(1).find('article');
|
|
return articles.toArray().map((elem) => {
|
|
const a = $(elem).find('header > a');
|
|
return {
|
|
title: a.find('h2').text(),
|
|
description: a.find('p').text(),
|
|
link: a.attr('href'),
|
|
pubDate: parseDate($(elem).find('footer').find('time').attr('datetime')),
|
|
category: $(elem)
|
|
.find('header div a')
|
|
.toArray()
|
|
.map((elem) => $(elem).text()),
|
|
};
|
|
});
|
|
}
|
|
|
|
module.exports = async (ctx) => {
|
|
const articles = await getArticles();
|
|
ctx.state.data = {
|
|
title: 'Blog | Apache APISIX',
|
|
link: 'https://apisix.apache.org/zh/blog/',
|
|
item: articles,
|
|
};
|
|
};
|