fix(route): 鱼塘热榜修复与优化 (#9214)

* fix: 鱼塘热榜图片显示,日期错误

* fix: use parseDate util

* fix: use single quotes

* fix: art template

* update: gif file extension
This commit is contained in:
Yorkin Yuan
2022-03-02 22:13:58 +08:00
committed by GitHub
parent cdc73efd4c
commit 271efc81ba
2 changed files with 25 additions and 9 deletions
+21 -9
View File
@@ -1,4 +1,7 @@
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 id = ctx.params.id;
@@ -13,17 +16,26 @@ module.exports = async (ctx) => {
const data = response.data.Data.data;
const title = `鱼塘热榜`;
const title = '鱼塘热榜';
ctx.state.data = {
title,
link: `https://mo.fish/`,
description: title,
item: data.map((item) => ({
title: item.Title,
pubDate: new Date(item.releaseTime).toUTCString(),
link: item.Url,
guid: item.id,
})),
link: 'https://mo.fish/',
item: data.map((item) => {
const isImage = Number(id) === 136 && item.Url.endsWith('.gif');
const description = isImage
? art(path.join(__dirname, 'templates/description.art'), {
imageUrl: item.Url,
})
: title;
return {
title: item.Title,
description,
pubDate: parseDate(item.CreateTime * 1000),
link: item.Url,
guid: item.id,
};
}),
};
};
@@ -0,0 +1,4 @@
<p>
<img src="{{ imageUrl }}" referrerpolicy="no-referrer">
<br>
</p>