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 = "";
|
||||
if (files[contentKey]) {
|
||||
const fullHtml = files[contentKey].contents.toString();
|
||||
// Extract body content (match what metalsmith-feed did)
|
||||
const bodyMatch = fullHtml.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
||||
renderedContent = bodyMatch ? bodyMatch[1].trim() : fullHtml;
|
||||
// Extract just the post content (not header/footer/navigation)
|
||||
// Match the article element which contains the actual post content
|
||||
const articleMatch = fullHtml.match(/<article[^>]*>([\s\S]*?)<\/article>/i);
|
||||
renderedContent = articleMatch ? articleMatch[1].trim() : fullHtml;
|
||||
}
|
||||
|
||||
feed.item({
|
||||
|
||||
Reference in new issue
Block a user