diff --git a/lib/routes/mofish/index.js b/lib/routes/mofish/index.js index aff04e293c..924e0cb438 100644 --- a/lib/routes/mofish/index.js +++ b/lib/routes/mofish/index.js @@ -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, + }; + }), }; }; diff --git a/lib/routes/mofish/templates/description.art b/lib/routes/mofish/templates/description.art new file mode 100644 index 0000000000..27cc225271 --- /dev/null +++ b/lib/routes/mofish/templates/description.art @@ -0,0 +1,4 @@ +
+
+
+