Skip to content

Commit

Permalink
feat(route): 增加少数派首页路由每篇文章的封面图片 (DIYgod#15716)
Browse files Browse the repository at this point in the history
* Update index.ts

* Update index.ts

* sspai index image
  • Loading branch information
Lfish authored May 26, 2024
1 parent d5ab30e commit 256f28e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/routes/sspai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ async function handler() {
const key = `sspai: ${item.id}`;
return cache.tryGet(key, async () => {
const response = await got({ method: 'get', url: link });
description = response.data.data.body;
const articleData = response.data.data;
let banner = articleData.banner;
if (articleData.keywords.includes('派早报')) {
banner = `https://cdnfile.sspai.com/${banner}`;
}
if (banner) {
description = `<img src="${banner}" alt="Article Cover Image" style="display: block; margin: 0 auto;"><br>`;
}
description += articleData.body;

return {
title: item.title.trim(),
Expand Down

0 comments on commit 256f28e

Please sign in to comment.