Use XSL to style RSS feed (thanks @iacore!)
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/manual/woodpecker Pipeline was successful
ci/woodpecker/deployment/woodpecker Pipeline was successful

This commit is contained in:
Anthony Wang 2024-02-24 22:54:12 -05:00
parent b3d234a0b0
commit 2534413a9f
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ
2 changed files with 36 additions and 0 deletions

35
public/rss.xsl Normal file
View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>
RSS Feed | <xsl:value-of select="//title"/>
</title>
<!-- where is the stylesheet? -->
<!-- <link rel="stylesheet" href="/assets/styles.css"/> -->
</head>
<body>
<p>
This is an RSS feed. Visit
<a href="https://aboutfeeds.com">About Feeds</a>
to learn more and get started.
</p>
<h1>RSS Feed | <xsl:value-of select="//title"/></h1>
<xsl:for-each select="//item">
<article>
<a>
<xsl:attribute name="href">
<xsl:value-of select="link"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</article>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View file

@ -18,5 +18,6 @@ export async function GET(context: { site: any; }) {
content: sanitizeHtml(parser.render(post.body)),
link: `/posts/${post.slug}`,
})) as RSSFeedItem[],
stylesheet: '/rss.xsl',
});
}