Skip to content

Commit a35ccb6

Browse files
committed
wip
1 parent 2a61a99 commit a35ccb6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/routes/rss[.]xml.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createFileRoute } from '@tanstack/react-router'
22
import { setResponseHeader } from '@tanstack/react-start/server'
3+
import { getPublishedPosts, formatAuthors } from '~/utils/blog'
34

45
function escapeXml(unsafe: string): string {
56
return unsafe
@@ -10,9 +11,7 @@ function escapeXml(unsafe: string): string {
1011
.replace(/'/g, ''')
1112
}
1213

13-
async function generateRSSFeed() {
14-
const { getPublishedPosts, formatAuthors } = await import('~/utils/blog')
15-
14+
function generateRSSFeed() {
1615
const posts = getPublishedPosts().slice(0, 50) // Most recent 50 posts
1716
const siteUrl = 'https://tanstack.com'
1817
const buildDate = new Date().toUTCString()
@@ -31,7 +30,7 @@ async function generateRSSFeed() {
3130
.replace(/^---[\s\S]*?---/, '')
3231
.trim()
3332
const firstParagraph = contentWithoutFrontmatter.split('\n\n')[0]
34-
description = firstParagraph.replace(/!\[[^\]]*]\([^)]*\)/g, '') // Remove images
33+
description = firstParagraph.replace(/!\[[^\]]*\]\([^)]*\)/g, '') // Remove images
3534
}
3635

3736
return `
@@ -62,11 +61,11 @@ async function generateRSSFeed() {
6261
}
6362

6463
export const Route = createFileRoute('/rss.xml')({
65-
// @ts-expect-error server property not in route types yet
64+
// @ts-ignore server property not in route types yet
6665
server: {
6766
handlers: {
6867
GET: async () => {
69-
const content = await generateRSSFeed()
68+
const content = generateRSSFeed()
7069

7170
setResponseHeader('Content-Type', 'application/xml; charset=utf-8')
7271
setResponseHeader(

0 commit comments

Comments
 (0)