RSS feeds have better links and render HTML in markdown content
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
|
import path from 'node:path';
|
||||||
import rss from '@astrojs/rss';
|
import rss from '@astrojs/rss';
|
||||||
import type { APIContext } from 'astro';
|
import type { APIContext } from 'astro';
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
import MarkdownIt from 'markdown-it';
|
import MarkdownIt from 'markdown-it';
|
||||||
|
|
||||||
const mdParser = new MarkdownIt();
|
const mdParser = new MarkdownIt({
|
||||||
|
html: true
|
||||||
|
});
|
||||||
|
|
||||||
export async function GET(context: APIContext) {
|
export async function GET(context: APIContext) {
|
||||||
// `site` is guaranteed to exist because we define it in our Astro config
|
// `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>
|
<image>/images/headshot.webp</image>
|
||||||
<language>en-GB</language>
|
<language>en-GB</language>
|
||||||
`,
|
`,
|
||||||
site,
|
site: path.join(site.toString(), 'blog'),
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
items: posts.map((post) => ({
|
items: posts.map((post) => ({
|
||||||
link: post.slug,
|
link: post.slug,
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
|
import path from 'node:path';
|
||||||
import rss from '@astrojs/rss';
|
import rss from '@astrojs/rss';
|
||||||
import type { APIContext } from 'astro';
|
import type { APIContext } from 'astro';
|
||||||
import LINKS from '../../data/links.ts';
|
import LINKS from '../../data/links.ts';
|
||||||
|
import MarkdownIt from 'markdown-it';
|
||||||
|
|
||||||
|
const mdParser = new MarkdownIt({
|
||||||
|
html: true
|
||||||
|
});
|
||||||
|
|
||||||
export async function GET(context: APIContext) {
|
export async function GET(context: APIContext) {
|
||||||
// `site` is guaranteed to exist because we define it in our Astro config
|
// `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>
|
<image>/images/headshot.webp</image>
|
||||||
<language>en-GB</language>
|
<language>en-GB</language>
|
||||||
`,
|
`,
|
||||||
site,
|
site: path.join(site.toString(), 'links'),
|
||||||
trailingSlash: false,
|
trailingSlash: false,
|
||||||
items: LINKS.map((link) => ({
|
items: LINKS.map((link) => ({
|
||||||
link: link.href,
|
link: link.href,
|
||||||
title: link.title,
|
title: link.title,
|
||||||
content: link.description,
|
content: mdParser.render(link.description),
|
||||||
pubDate: new Date(link.isoDateAdded),
|
pubDate: new Date(link.isoDateAdded),
|
||||||
description: link.description,
|
description: mdParser.render(link.description),
|
||||||
author: 'Joe Carstairs',
|
author: 'Joe Carstairs',
|
||||||
})),
|
})),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user