Files
RSSHub/lib/v2/ff14/ff14_global.js
railzy d1173f34ac fix(route): 最终幻想 14 国际服 Lodestone 内容api调用格式更新 (#9260)
* fix(route): 最终幻想 14 国际服 Lodestone 内容api调用格式更新

* ff14 国际服 lodestone api 使用 https

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

Co-authored-by: Tony <TonyRL@users.noreply.github.com>
2022-03-07 18:19:14 +08:00

38 lines
1.1 KiB
JavaScript

const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const lang = ctx.params.lang;
const type = ctx.params.type ?? 'all';
const response = await got({
method: 'get',
url: `https://lodestonenews.com/news/${type}?locale=${lang}`,
});
let data;
if (type === 'all') {
data = [];
Object.values(response.data).forEach((arr) => (data = data.concat(arr)));
} else {
data = response.data;
}
ctx.state.data = {
title: `FFXIV Lodestone updates (${type})`,
link: `https://${lang}.finalfantasyxiv.com/lodestone/news/`,
item: data.map(({ id, url, title, time, description, image }) => ({
title,
link: url,
description: art(path.join(__dirname, 'templates/description.art'), {
image,
description,
}),
pubDate: parseDate(time),
guid: id,
})),
};
};