From b6079568c85401b9dc3dede6c980d6ef67882647 Mon Sep 17 00:00:00 2001 From: VinceCYLiao Date: Wed, 19 Jul 2023 00:26:31 +0800 Subject: [PATCH] fix: #9136:fix(content-blog): links in feed should be absolute --- packages/docusaurus-plugin-content-blog/src/feed.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/docusaurus-plugin-content-blog/src/feed.ts b/packages/docusaurus-plugin-content-blog/src/feed.ts index dc9a7b85f84c..9efc84e16ccf 100644 --- a/packages/docusaurus-plugin-content-blog/src/feed.ts +++ b/packages/docusaurus-plugin-content-blog/src/feed.ts @@ -106,6 +106,14 @@ async function defaultCreateFeedItems({ const $ = cheerioLoad(content); const link = normalizeUrl([siteUrl, permalink]); + + $(`div#${blogPostContainerID} a`).each((_, elm) => { + const {href} = elm.attribs; + if (href) { + elm.attribs.href = String(new URL(href, link)); + } + }); + const feedItem: BlogFeedItem = { title: metadataTitle, id: link,