feat(route): Add 十年之约-专题展示 (#11382)
* Add 十年之约-专题展示 * Fix linux linter * fix MR comments * Triggle CI again * Putting postDate in pubDate * Change path from foreverblog-cn to foreverblog * fix: merge old route fix: radar target
This commit is contained in:
+2
-2
@@ -316,9 +316,9 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog
|
||||
|
||||
## 十年之约
|
||||
|
||||
### 文章
|
||||
### 专题展示 - 文章
|
||||
|
||||
<Route author="7Wate" example="/blogs/foreverblog" path="/blogs/foreverblog" />
|
||||
<Route author="7Wate a180285" example="/foreverblog/feeds" path="/foreverblog/feeds" radar="1" rssbud="1" />
|
||||
|
||||
## 王五四文集
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://www.foreverblog.cn/feeds.html',
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('article[class="post post-type-normal"]');
|
||||
|
||||
ctx.state.data = {
|
||||
title: '十年之约 - 订阅',
|
||||
link: 'https://www.foreverblog.cn/feeds.html',
|
||||
language: 'zh-cn',
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('a.post-title-link>span').text(),
|
||||
description: item.find('div.post-author').text(),
|
||||
link: item.find('a.post-title-link').attr('href'),
|
||||
pubDate: item.find('time.post-time').text(),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = 'https://www.foreverblog.cn/feeds.html';
|
||||
|
||||
const response = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const $articles = $('article[class="post post-type-normal"]');
|
||||
const items = $articles
|
||||
.map((_, el) => {
|
||||
const $titleDiv = $(el).find('h1[class="post-title"]');
|
||||
const title = $titleDiv.text().trim();
|
||||
const link = $titleDiv.find('a').eq(0).attr('href');
|
||||
const author = $(el).find('div[class="post-author"]').text().trim();
|
||||
const postDate = $(el).find('time').text().trim();
|
||||
const pubDate = timezone(parseDate(postDate, 'MM-DD'), +8);
|
||||
const description = `${author}: ${title}`;
|
||||
return {
|
||||
title: description,
|
||||
description,
|
||||
link,
|
||||
pubDate,
|
||||
};
|
||||
})
|
||||
.toArray();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '十年之约——专题展示',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/feeds': ['7Wate', 'a180285'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'foreverblog.cn': {
|
||||
_name: '十年之约',
|
||||
www: [
|
||||
{
|
||||
title: '专题展示',
|
||||
docs: 'https://docs.rsshub.app/blog.html#shi-nian-zhi-yue',
|
||||
source: ['/feeds.html'],
|
||||
target: '/foreverblog/feeds',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/feeds', require('./feeds'));
|
||||
};
|
||||
Reference in New Issue
Block a user