optimize directory structure

This commit is contained in:
DIYgod
2018-12-26 18:35:10 +08:00
parent c68251e461
commit 38a90e29b0
475 changed files with 52 additions and 52 deletions

View File

@@ -0,0 +1,47 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
const column_id = ctx.params.cid;
// Get column introduction including column name and description
const intro_response = await axios({
method: 'post',
url: 'https://time.geekbang.org/serv/v1/column/intro',
headers: {
Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
},
data: {
cid: column_id,
},
});
const intro_data = intro_response.data.data;
// Get latest articles
const latest_response = await axios({
method: 'post',
url: 'https://time.geekbang.org/serv/v1/column/articles/latest',
headers: {
Referer: 'https://time.geekbang.org/',
'Content-Type': 'application/json',
},
data: {
cid: column_id,
},
});
const articles = latest_response.data.data.list;
ctx.state.data = {
title: intro_data.column_title,
link: `https://time.geekbang.org/column/intro/${column_id}`,
description: intro_data.column_subtitle,
item: articles.map((item) => ({
title: item.article_title,
description: item.article_summary,
pubDate: new Date(item.article_ctime * 1000).toUTCString(),
link: `https://time.geekbang.org/column/article/${item.id}`,
})),
};
};