Skip to content

Commit 97446e9

Browse files
committed
Add XSL stylesheet for RSS feed formatting
1 parent 8780e3a commit 97446e9

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

public/rss/styles.xsl

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3+
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
4+
<xsl:template match="/">
5+
<html>
6+
<head>
7+
<title>RSS Feed</title>
8+
<style>
9+
body {
10+
font-family: Arial, sans-serif;
11+
line-height: 1.6;
12+
margin: 0;
13+
padding: 0;
14+
background-color: #f4f4f4;
15+
}
16+
.container {
17+
width: 80%;
18+
margin: auto;
19+
overflow: hidden;
20+
}
21+
ul {
22+
list-style: none;
23+
padding: 0;
24+
}
25+
li {
26+
background: #fff;
27+
margin: 0.5em 0;
28+
padding: 1em;
29+
border-radius: 5px;
30+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
31+
}
32+
a {
33+
color: #00539f;
34+
text-decoration: none;
35+
}
36+
a:hover {
37+
text-decoration: underline;
38+
}
39+
</style>
40+
</head>
41+
<body>
42+
<div class="container">
43+
<h1>RSS Feed</h1>
44+
<ul>
45+
<xsl:for-each select="rss/channel/item">
46+
<li>
47+
<h2><a href="{link}"><xsl:value-of select="title"/></a></h2>
48+
<p><xsl:value-of select="description"/></p>
49+
<small><xsl:value-of select="pubDate"/></small>
50+
</li>
51+
</xsl:for-each>
52+
</ul>
53+
</div>
54+
</body>
55+
</html>
56+
</xsl:template>
57+
</xsl:stylesheet>

src/pages/rss.xml.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export async function GET(context) {
1414
link: `/posts/${post.data.slug}/`,
1515
})),
1616
customData: `<language>en-us</language>`,
17+
stylesheet: '/rss/styles.xsl',
1718
});
1819
}

0 commit comments

Comments
 (0)