mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-19 06:38:55 +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:
18
docs/blog.md
18
docs/blog.md
@@ -16,6 +16,12 @@ pageClass: routes
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## Apache
|
||||||
|
|
||||||
|
### APISIX 博客
|
||||||
|
|
||||||
|
<Route author="aneasystone" example="/apache/apisix/blog" path="/apache/apisix/blog"/>
|
||||||
|
|
||||||
## archdaily
|
## archdaily
|
||||||
|
|
||||||
### 首页
|
### 首页
|
||||||
@@ -411,6 +417,18 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog
|
|||||||
|
|
||||||
<Route author="XinRoom" example="/ddosi/category/黑客工具" path="/ddosi/category/:category?"/>
|
<Route author="XinRoom" example="/ddosi/category/黑客工具" path="/ddosi/category/:category?"/>
|
||||||
|
|
||||||
|
## 云原生社区
|
||||||
|
|
||||||
|
### 博客
|
||||||
|
|
||||||
|
<Route author="aneasystone" example="/cloudnative/blog" path="/cloudnative/blog"/>
|
||||||
|
|
||||||
|
## 支流科技
|
||||||
|
|
||||||
|
### 博客
|
||||||
|
|
||||||
|
<Route author="aneasystone" example="/apiseven/blog" path="/apiseven/blog"/>
|
||||||
|
|
||||||
## 竹白
|
## 竹白
|
||||||
|
|
||||||
### 文章
|
### 文章
|
||||||
|
|||||||
32
lib/v2/apache/apisix/blog.js
Normal file
32
lib/v2/apache/apisix/blog.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
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,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/apache/maintainer.js
Normal file
3
lib/v2/apache/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/apisix/blog': ['aneasystone'],
|
||||||
|
};
|
||||||
13
lib/v2/apache/radar.js
Normal file
13
lib/v2/apache/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'apache.org': {
|
||||||
|
_name: 'Apache',
|
||||||
|
apisix: [
|
||||||
|
{
|
||||||
|
title: 'APISIX 博客',
|
||||||
|
docs: 'https://docs.rsshub.app/blog.html#apache',
|
||||||
|
source: ['/zh/blog'],
|
||||||
|
target: () => '/apache/apisix/blog',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/apache/router.js
Normal file
3
lib/v2/apache/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/apisix/blog', require('./apisix/blog'));
|
||||||
|
};
|
||||||
46
lib/v2/apiseven/blog.js
Normal file
46
lib/v2/apiseven/blog.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
const timezone = require('@/utils/timezone');
|
||||||
|
const md = require('markdown-it')({
|
||||||
|
html: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getArticles() {
|
||||||
|
const url = 'https://www.apiseven.com/blog';
|
||||||
|
const { data: res } = await got(url);
|
||||||
|
const $ = cheerio.load(res);
|
||||||
|
const json = JSON.parse($('#__NEXT_DATA__').text());
|
||||||
|
return json.props.pageProps.list.map((item) => ({
|
||||||
|
title: item.title,
|
||||||
|
link: 'https://www.apiseven.com' + item.slug,
|
||||||
|
pubDate: timezone(parseDate(item.published_at), +8),
|
||||||
|
category: item.tags,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const articles = await getArticles();
|
||||||
|
const items = await Promise.all(
|
||||||
|
articles.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const { data: res } = await got(item.link);
|
||||||
|
const $ = cheerio.load(res);
|
||||||
|
const json = JSON.parse($('#__NEXT_DATA__').text());
|
||||||
|
return {
|
||||||
|
title: item.title,
|
||||||
|
description: md.render(json.props.pageProps.post.content),
|
||||||
|
link: item.link,
|
||||||
|
pubDate: item.pubDate,
|
||||||
|
author: json.props.pageProps.post.author_name,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '博客 | 支流科技',
|
||||||
|
link: 'https://www.apiseven.com/blog',
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/apiseven/maintainer.js
Normal file
3
lib/v2/apiseven/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/blog': ['aneasystone'],
|
||||||
|
};
|
||||||
13
lib/v2/apiseven/radar.js
Normal file
13
lib/v2/apiseven/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'apiseven.com': {
|
||||||
|
_name: '支流科技',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '博客',
|
||||||
|
docs: 'https://docs.rsshub.app/blog.html#zhi-liu-ke-ji',
|
||||||
|
source: ['/blog'],
|
||||||
|
target: () => '/apiseven/blog',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/apiseven/router.js
Normal file
3
lib/v2/apiseven/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/blog', require('./blog'));
|
||||||
|
};
|
||||||
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,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/cloudnative/maintainer.js
Normal file
3
lib/v2/cloudnative/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/blog': ['aneasystone'],
|
||||||
|
};
|
||||||
13
lib/v2/cloudnative/radar.js
Normal file
13
lib/v2/cloudnative/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'cloudnative.to': {
|
||||||
|
_name: '云原生社区',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '博客',
|
||||||
|
docs: 'https://docs.rsshub.app/blog.html#yun-yuan-sheng-she-qu',
|
||||||
|
source: ['/blog'],
|
||||||
|
target: () => '/cloudnative/blog',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/cloudnative/router.js
Normal file
3
lib/v2/cloudnative/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = (router) => {
|
||||||
|
router.get('/blog', require('./blog'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user