From 02ba52cefcb53b03c1f67319c8f4c817a5ec0300 Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Mon, 26 Jan 2026 14:10:03 +0100 Subject: [PATCH] feat: add new XSL template for the RSS feed --- public/rss.xsl | 250 ++++++++++++++++++++++++++----------------- src/pages/rss.xml.js | 39 ++++++- 2 files changed, 185 insertions(+), 104 deletions(-) diff --git a/public/rss.xsl b/public/rss.xsl index 64c14ae..25a5c59 100644 --- a/public/rss.xsl +++ b/public/rss.xsl @@ -1,111 +1,161 @@ - - + + - - - <xsl:value-of select="/rss/channel/title"/> Web Feed - - - - - -
-
-

- - - - - - - - - - - - - - - - - + article { + border-block-start: 1px solid light-dark(var(--linkLight), var(--linkDark)); + clear: both; + padding-block: 1em; + } - Web Feed Preview -

-

-

- - - - - Visit Website → - -
-

Recent Items

- -
-

- - - - - - -

- - Published: - + h1 { + font-size: clamp(20px, 2vw, 50px); + } + + h2 { + font-size: clamp(15px, 1.2vw, 40px); + margin-block-end: 0.5em; + } + + h3 { + font-size: clamp(12px, 1vw, 30px); + line-height: 1; + margin-block-end: 0.5em; + margin-block-start: 0; + } + + img { + float: inline-start; + margin-inline-end: 1em; + margin-block-end: 1.5em; + } + + small, + .timestamp { + font-size: clamp(10px, 0.8vw, 15px); + margin-block: 0; + } + + a { + color: light-dark(var(--textLight), var(--textDark)); + text-decoration-line: none; + text-size-adjust: 100%; + text-underline-offset: auto; + } + + a:hover, + a:active, + a:focus { + text-decoration-color: var(--accent); + text-decoration-line: underline; + text-decoration-style: solid; + text-decoration-thickness: 4px; + } + + .timestamp { + color: light-dark(var(--linkLight), var(--linkDark)); + font-style: italic; + } + + .title { + margin-block-end: 0; + } + + .description { + margin-block-start: 0; + } + + + + + +
+
+

+ + + + Web Feed Preview +

+

+ +

+

+ +

+ + + + + Visit Website + +
+

Recent Items

+ +
+ + {title} + +
+
- -
- +

+ + + + + + +

+ + + + +
+ + diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index ce8f50a..2cff9c2 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -21,6 +21,9 @@ export async function GET(context) { title: site.title, description: site.description, site: context.site, + xmlns: { + media: 'http://search.yahoo.com/mrss/', + }, items: [ ...journal.map((post) => { // Filter out import statements from content @@ -48,18 +51,37 @@ export async function GET(context) { }, }); + // Logic to determine image URL + const isWebp = + post.data.cover.startsWith('/assets/images/cover/') && + post.data.cover.endsWith('.webp'); + const imgUrl = isWebp + ? post.data.cover + .replace('/assets/images/cover/', '/assets/images/thumbnail/') + .replace(/\.webp$/, '.jpg') + : '/assets/images/thumbnail/bonsai.jpg'; + return { title: post.data.title, pubDate: post.data.date, - description: ``, + description: post.data.description, link: `/${post.slug}/`, - content: ``, + content: sanitizedContent, enclosure: { - url: `${site.url}${post.data.cover.startsWith('/assets/images/cover/') && post.data.cover.endsWith('.webp') ? post.data.cover.replace('/assets/images/cover/', '/assets/images/og/').replace(/\.webp$/, '.jpg') : '/assets/images/og/bonsai.jpg'}`, + url: + site.url + + (isWebp + ? post.data.cover + .replace('/assets/images/cover/', '/assets/images/og/') + .replace(/\.webp$/, '.jpg') + : '/assets/images/og/bonsai.jpg'), length: 0, type: 'image/jpeg', }, - customData: 'en-us', + customData: ` + en-us + + `, }; }), ...haiku.map((item) => { @@ -69,6 +91,15 @@ export async function GET(context) { customData: 'en-us', link: `/haiku/${item.slug}/`, content: `

${item.data.de}


${item.data.en}

`, + enclosure: { + url: `${site.url}'/assets/images/og/bonsai.jpg`, + length: 0, + type: 'image/jpeg', + }, + customData: ` + en-us + + `, }; }), ].sort((a, b) => b.pubDate.valueOf() - a.pubDate.valueOf()),