diff options
| author | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-06-05 17:03:04 +0100 |
|---|---|---|
| committer | Joe Carstairs <jcarstairs@scottlogic.com> | 2024-06-05 17:03:04 +0100 |
| commit | a9c8d7772a4421eaee63a806fd947fb39743745e (patch) | |
| tree | c708733a9d65d5ec4c25a88151545566575a58e5 | |
| parent | 81ef51422fe31c8de41b9d06942ce8b83346253e (diff) | |
RSS feeds have better links and render HTML in markdown content
| -rw-r--r-- | website/src/pages/blog/rss.xml.ts | 7 | ||||
| -rw-r--r-- | website/src/pages/links/rss.xml.ts | 12 |
2 files changed, 14 insertions, 5 deletions
diff --git a/website/src/pages/blog/rss.xml.ts b/website/src/pages/blog/rss.xml.ts index b7c9bf3..ae81209 100644 --- a/website/src/pages/blog/rss.xml.ts +++ b/website/src/pages/blog/rss.xml.ts @@ -1,9 +1,12 @@ +import path from 'node:path'; import rss from '@astrojs/rss'; import type { APIContext } from 'astro'; import { getCollection } from 'astro:content'; import MarkdownIt from 'markdown-it'; -const mdParser = new MarkdownIt(); +const mdParser = new MarkdownIt({ + html: true +}); export async function GET(context: APIContext) { // `site` is guaranteed to exist because we define it in our Astro config @@ -17,7 +20,7 @@ export async function GET(context: APIContext) { <image>/images/headshot.webp</image> <language>en-GB</language> `, - site, + site: path.join(site.toString(), 'blog'), trailingSlash: false, items: posts.map((post) => ({ link: post.slug, diff --git a/website/src/pages/links/rss.xml.ts b/website/src/pages/links/rss.xml.ts index 009588a..3f9e9a0 100644 --- a/website/src/pages/links/rss.xml.ts +++ b/website/src/pages/links/rss.xml.ts @@ -1,6 +1,12 @@ +import path from 'node:path'; import rss from '@astrojs/rss'; import type { APIContext } from 'astro'; import LINKS from '../../data/links.ts'; +import MarkdownIt from 'markdown-it'; + +const mdParser = new MarkdownIt({ + html: true +}); export async function GET(context: APIContext) { // `site` is guaranteed to exist because we define it in our Astro config @@ -13,14 +19,14 @@ export async function GET(context: APIContext) { <image>/images/headshot.webp</image> <language>en-GB</language> `, - site, + site: path.join(site.toString(), 'links'), trailingSlash: false, items: LINKS.map((link) => ({ link: link.href, title: link.title, - content: link.description, + content: mdParser.render(link.description), pubDate: new Date(link.isoDateAdded), - description: link.description, + description: mdParser.render(link.description), author: 'Joe Carstairs', })), }) |
