feat(route): add CNCF (#9790)
* feat(route): add CNCF * Update docs/en/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update docs/programming.md Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/v2/cncf/maintainer.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> Co-authored-by: Tony <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -82,6 +82,18 @@ Category
|
||||
|
||||
<RouteEn author="elxy" example="/bitmovin/blog" path="/bitmovin/blog"/>
|
||||
|
||||
## CNCF
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="Fatpandac" example="/cncf" path="/cncf/:cate?" radar="1" rssbud="1" :paramsDesc="['blog by default']">
|
||||
|
||||
| Blog | News | Announcements | Reports |
|
||||
|------|------|---------------|---------|
|
||||
| blog | news | announcements | reports |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## Codeforces
|
||||
|
||||
### Latest contests
|
||||
|
||||
@@ -96,6 +96,18 @@ Rated 对象
|
||||
|
||||
<Route author="elxy" example="/bitmovin/blog" path="/bitmovin/blog"/>
|
||||
|
||||
## CNCF
|
||||
|
||||
### 栏目
|
||||
|
||||
<Route author="Fatpandac" example="/cncf" path="/cncf/:cate?" :paramsDesc="['默认为 blog']">
|
||||
|
||||
| Blog | News | Announcements | Reports |
|
||||
| ---- | ---- | ------------- | ------- |
|
||||
| blog | news | announcements | reports |
|
||||
|
||||
</Route>
|
||||
|
||||
## Codeforces
|
||||
|
||||
#### 最新比赛
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootURL = 'https://www.cncf.io';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cate = ctx.params.cate ?? 'blog';
|
||||
const url = `${rootURL}/${cate}/`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = $('h1.is-style-page-title').text();
|
||||
const list = $('div.post-archive__item')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('span.post-archive__title').text().trim(),
|
||||
link: $(item).find('span.post-archive__title > a').attr('href'),
|
||||
pubDate: parseDate($(item).find('span.post-archive__item_date').text().split('|')[0]),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('div.post-author').remove();
|
||||
content('div.social-share').remove();
|
||||
|
||||
item.description = content('article').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `CNCF - ${title}`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:cate?': ['Fatpandac'],
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
'cncf.io': {
|
||||
_name: 'CNCF',
|
||||
'.': [
|
||||
{
|
||||
title: 'Blog',
|
||||
docs: 'https://docs.rsshub.app/programming.html#cncf',
|
||||
source: ['/blog'],
|
||||
target: '/cncf/blog',
|
||||
},
|
||||
{
|
||||
title: 'News',
|
||||
docs: 'https://docs.rsshub.app/programming.html#cncf',
|
||||
source: ['/news'],
|
||||
target: '/cncf/news',
|
||||
},
|
||||
{
|
||||
title: 'Announcements',
|
||||
docs: 'https://docs.rsshub.app/programming.html#cncf',
|
||||
source: ['/announcements'],
|
||||
target: '/cncf/announcements',
|
||||
},
|
||||
{
|
||||
title: 'Reports',
|
||||
docs: 'https://docs.rsshub.app/programming.html#cncf',
|
||||
source: ['/reports'],
|
||||
target: '/cncf/reports',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const rootURL = 'https://www.cncf.io';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = `${rootURL}/reports/`;
|
||||
|
||||
const response = await got(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('div.report-item')
|
||||
.map((_index, item) => ({
|
||||
title: $(item).find('a.report-item__link').attr('title'),
|
||||
link: $(item).find('a.report-item__link').attr('href'),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got(item.link);
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.parseDate = parseDate(content('p.is-style-spaced-uppercase').splice(':')[1]);
|
||||
item.description = content('article > div.has-background').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `CNCF - Reports`,
|
||||
link: url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/reports', require('./reports'));
|
||||
router.get('/:cate?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user