feat: add diygod blog

This commit is contained in:
DIYgod
2020-03-24 19:23:05 +08:00
parent 398c815106
commit 9b53436084
4 changed files with 88 additions and 0 deletions

View File

@@ -36,6 +36,16 @@ pageClass: routes
<Route author="aha2mao" example="/hexo/yilia/cloudstone.xin" path="/hexo/yilia/:url" :paramsDesc="['博客 Url 不带协议头']"/>
## Hi, DIYgod
### DIYgod 的动森日记
<Route author="DIYgod" example="/blogs/diygod/animal-crossing" path="/blogs/diygod/animal-crossing"/>
### DIYgod 的可爱的手办们
<Route author="DIYgod" example="/blogs/diygod/gk" path="/blogs/diygod/gk"/>
## LaTeX 开源小屋
### 首页

View File

@@ -2424,4 +2424,8 @@ router.get('/checkra1n/releases', require('./routes/checkra1n/releases'));
// 四川省科学技术厅
router.get('/sckjt/news/:type?', require('./routes/sckjt/news'));
// Hi, DIYgod
router.get('/blogs/diygod/animal-crossing', require('./routes/blogs/diygod/animal-crossing'));
router.get('/blogs/diygod/gk', require('./routes/blogs/diygod/gk'));
module.exports = router;

View File

@@ -0,0 +1,37 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://diygod.me/animal-crossing',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('h3');
ctx.state.data = {
title: 'DIYgod 的动森日记',
link: 'https://diygod.me/animal-crossing',
item:
list &&
list
.map((index, item) => {
item = $(item);
let description = '';
item.nextUntil('h3').each((index, item) => {
description += $(item).html();
});
return {
title: item.text(),
description,
link: `https://diygod.me/animal-crossing/#${item.attr('id')}`,
pubDate: date(item.text().split(' ')[1]),
};
})
.get(),
};
};

View File

@@ -0,0 +1,37 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://diygod.me/gk',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('.gk-item');
ctx.state.data = {
title: 'DIYgod 的动森日记',
link: 'https://diygod.me/animal-crossing',
item:
list &&
list
.map((index, item) => {
item = $(item);
const title = item
.find('.gk-desc p')
.eq(0)
.text()
.slice(3);
return {
title,
description: item.html(),
link: 'https://diygod.me/gk',
guid: title,
};
})
.get(),
};
};