Skip to content

Commit

Permalink
feat(route): fix images not displaying in msn news full text (DIYgod#…
Browse files Browse the repository at this point in the history
…18017)

* feat(route): fix images not displaying in msn news full text

* feat(route): fix images not displaying in msn news full text
  • Loading branch information
KTachibanaM authored Jan 3, 2025
1 parent 7d1fa06 commit 3da0721
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/routes/msn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cache from '@/utils/cache';
import { load } from 'cheerio';

const apiKey = '0QfOX3Vn51YCzitbLaRkTTBadtWpgTN8NZLW0C1SEM';
const fetchedArticleContentHtmlImgRegex = /<img data-reference="image" data-document-id="cms\/api\/amp\/image\/([A-Za-z0-9]+)">/;

export const route: Route = {
path: '/:market/:name/:id',
Expand Down Expand Up @@ -57,8 +58,8 @@ export const route: Route = {
const fetchedArticleContentHtml = (await cache.tryGet(articleId, async () => {
const articleData = await ofetch(`https://assets.msn.com/content/view/v2/Detail/${market}/${articleId}`);
return articleData.body;
})) as string; // cache article content for 3 months
articleContentHtml = fetchedArticleContentHtml;
})) as string;
articleContentHtml = fetchedArticleContentHtml.replace(fetchedArticleContentHtmlImgRegex, '<img src="https://img-s-msn-com.akamaized.net/tenant/amp/entityid/$1.img">');
}

return {
Expand Down

0 comments on commit 3da0721

Please sign in to comment.