Files
ZeroClad 0eb8c08a96 fix(route): ff14 修改 pubDate 为原文发布时间 (#7234)
* fix: 修改 pubDate 为原文发布时间

* refactor(route): migrate to v2

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2022-02-16 05:22:05 +08:00

44 lines
1.5 KiB
JavaScript

const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const referer = 'https://ff.sdo.com/web8/index.html';
const type = ctx.params.type ?? 'all';
const type_number = {
news: '5310',
announce: '5312',
events: '5311',
advertise: '5313',
all: '5310,5312,5311,5313,5309',
};
const response = await got({
method: 'get',
url: `http://api.act.sdo.com/UnionNews/List?gameCode=ff&category=${type_number[type]}&pageIndex=0&pageSize=50`,
headers: {
Referer: referer,
},
});
const data = response.data.Data;
ctx.state.data = {
title: '最终幻想14(国服)新闻中心',
link: referer + '#/newstab/newslist',
description: '《最终幻想14》是史克威尔艾尼克斯出品的全球经典游戏品牌FINAL FANTASY系列的最新作品,IGN获得9.2高分!全球累计用户突破1600万!',
item: data.map(({ Title, Summary, Author, PublishDate, HomeImagePath }) => ({
title: Title,
link: Author,
description: art(path.join(__dirname, 'templates/description.art'), {
image: HomeImagePath,
description: Summary,
}),
pubDate: timezone(parseDate(PublishDate), +8),
})),
};
};