fix: RSS feed description contains only article content, not full page
Extract just the <article> element (title + body) for feed descriptions, removing header, navigation, share buttons, and footer.
This commit is contained in:
1 parent
334fa146c7
commit
25186c75b9
1 file changed
+4
-3
@@ -172,9 +172,10 @@ function feedPlugin() {
|
|||||||
let renderedContent = "";
|
let renderedContent = "";
|
||||||
if (files[contentKey]) {
|
if (files[contentKey]) {
|
||||||
const fullHtml = files[contentKey].contents.toString();
|
const fullHtml = files[contentKey].contents.toString();
|
||||||
// Extract body content (match what metalsmith-feed did)
|
// Extract just the post content (not header/footer/navigation)
|
||||||
const bodyMatch = fullHtml.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
// Match the article element which contains the actual post content
|
||||||
renderedContent = bodyMatch ? bodyMatch[1].trim() : fullHtml;
|
const articleMatch = fullHtml.match(/<article[^>]*>([\s\S]*?)<\/article>/i);
|
||||||
|
renderedContent = articleMatch ? articleMatch[1].trim() : fullHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
feed.item({
|
feed.item({
|
||||||
|
|||||||
Reference in new issue
Block a user