Skip to content

Commit 249e2ee

Browse files
committed
feat: add RSS feed link to blog header and improve RSS feed generation
1 parent 93ab575 commit 249e2ee

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

src/routeTree.gen.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import { Route as LibrariesMaintainersRouteImport } from './routes/_libraries/ma
4545
import { Route as LibrariesLoginRouteImport } from './routes/_libraries/login'
4646
import { Route as LibrariesLearnRouteImport } from './routes/_libraries/learn'
4747
import { Route as LibrariesFeedbackLeaderboardRouteImport } from './routes/_libraries/feedback-leaderboard'
48-
import { Route as LibrariesExploreRouteImport } from './routes/_libraries/explore'
4948
import { Route as LibrariesEthosRouteImport } from './routes/_libraries/ethos'
5049
import { Route as LibrariesDashboardRouteImport } from './routes/_libraries/dashboard'
5150
import { Route as LibrariesBrandGuideRouteImport } from './routes/_libraries/brand-guide'
@@ -284,11 +283,6 @@ const LibrariesFeedbackLeaderboardRoute =
284283
path: '/feedback-leaderboard',
285284
getParentRoute: () => LibrariesRouteRoute,
286285
} as any)
287-
const LibrariesExploreRoute = LibrariesExploreRouteImport.update({
288-
id: '/explore',
289-
path: '/explore',
290-
getParentRoute: () => LibrariesRouteRoute,
291-
} as any)
292286
const LibrariesEthosRoute = LibrariesEthosRouteImport.update({
293287
id: '/ethos',
294288
path: '/ethos',
@@ -614,7 +608,6 @@ export interface FileRoutesByFullPath {
614608
'/brand-guide': typeof LibrariesBrandGuideRoute
615609
'/dashboard': typeof LibrariesDashboardRoute
616610
'/ethos': typeof LibrariesEthosRoute
617-
'/explore': typeof LibrariesExploreRoute
618611
'/feedback-leaderboard': typeof LibrariesFeedbackLeaderboardRoute
619612
'/learn': typeof LibrariesLearnRoute
620613
'/login': typeof LibrariesLoginRoute
@@ -705,7 +698,6 @@ export interface FileRoutesByTo {
705698
'/brand-guide': typeof LibrariesBrandGuideRoute
706699
'/dashboard': typeof LibrariesDashboardRoute
707700
'/ethos': typeof LibrariesEthosRoute
708-
'/explore': typeof LibrariesExploreRoute
709701
'/feedback-leaderboard': typeof LibrariesFeedbackLeaderboardRoute
710702
'/learn': typeof LibrariesLearnRoute
711703
'/login': typeof LibrariesLoginRoute
@@ -801,7 +793,6 @@ export interface FileRoutesById {
801793
'/_libraries/brand-guide': typeof LibrariesBrandGuideRoute
802794
'/_libraries/dashboard': typeof LibrariesDashboardRoute
803795
'/_libraries/ethos': typeof LibrariesEthosRoute
804-
'/_libraries/explore': typeof LibrariesExploreRoute
805796
'/_libraries/feedback-leaderboard': typeof LibrariesFeedbackLeaderboardRoute
806797
'/_libraries/learn': typeof LibrariesLearnRoute
807798
'/_libraries/login': typeof LibrariesLoginRoute
@@ -898,7 +889,6 @@ export interface FileRouteTypes {
898889
| '/brand-guide'
899890
| '/dashboard'
900891
| '/ethos'
901-
| '/explore'
902892
| '/feedback-leaderboard'
903893
| '/learn'
904894
| '/login'
@@ -989,7 +979,6 @@ export interface FileRouteTypes {
989979
| '/brand-guide'
990980
| '/dashboard'
991981
| '/ethos'
992-
| '/explore'
993982
| '/feedback-leaderboard'
994983
| '/learn'
995984
| '/login'
@@ -1084,7 +1073,6 @@ export interface FileRouteTypes {
10841073
| '/_libraries/brand-guide'
10851074
| '/_libraries/dashboard'
10861075
| '/_libraries/ethos'
1087-
| '/_libraries/explore'
10881076
| '/_libraries/feedback-leaderboard'
10891077
| '/_libraries/learn'
10901078
| '/_libraries/login'
@@ -1444,13 +1432,6 @@ declare module '@tanstack/react-router' {
14441432
preLoaderRoute: typeof LibrariesFeedbackLeaderboardRouteImport
14451433
parentRoute: typeof LibrariesRouteRoute
14461434
}
1447-
'/_libraries/explore': {
1448-
id: '/_libraries/explore'
1449-
path: '/explore'
1450-
fullPath: '/explore'
1451-
preLoaderRoute: typeof LibrariesExploreRouteImport
1452-
parentRoute: typeof LibrariesRouteRoute
1453-
}
14541435
'/_libraries/ethos': {
14551436
id: '/_libraries/ethos'
14561437
path: '/ethos'
@@ -1950,7 +1931,6 @@ interface LibrariesRouteRouteChildren {
19501931
LibrariesBrandGuideRoute: typeof LibrariesBrandGuideRoute
19511932
LibrariesDashboardRoute: typeof LibrariesDashboardRoute
19521933
LibrariesEthosRoute: typeof LibrariesEthosRoute
1953-
LibrariesExploreRoute: typeof LibrariesExploreRoute
19541934
LibrariesFeedbackLeaderboardRoute: typeof LibrariesFeedbackLeaderboardRoute
19551935
LibrariesLearnRoute: typeof LibrariesLearnRoute
19561936
LibrariesLoginRoute: typeof LibrariesLoginRoute
@@ -1987,7 +1967,6 @@ const LibrariesRouteRouteChildren: LibrariesRouteRouteChildren = {
19871967
LibrariesBrandGuideRoute: LibrariesBrandGuideRoute,
19881968
LibrariesDashboardRoute: LibrariesDashboardRoute,
19891969
LibrariesEthosRoute: LibrariesEthosRoute,
1990-
LibrariesExploreRoute: LibrariesExploreRoute,
19911970
LibrariesFeedbackLeaderboardRoute: LibrariesFeedbackLeaderboardRoute,
19921971
LibrariesLearnRoute: LibrariesLearnRoute,
19931972
LibrariesLoginRoute: LibrariesLoginRoute,

src/routes/_libraries/blog.index.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Footer } from '~/components/Footer'
77
import { PostNotFound } from './blog'
88
import { createServerFn } from '@tanstack/react-start'
99
import { setResponseHeaders } from '@tanstack/react-start/server'
10+
import { RssIcon } from 'lucide-react'
1011

1112
type BlogFrontMatter = {
1213
slug: string
@@ -65,7 +66,19 @@ function BlogIndex() {
6566
<div className="flex flex-col max-w-full min-h-screen gap-12 p-4 md:p-8 pb-0">
6667
<div className="flex-1 space-y-12 w-full max-w-4xl mx-auto">
6768
<header className="">
68-
<h1 className="text-3xl font-black">Blog</h1>
69+
<div className="flex gap-3 items-baseline">
70+
<h1 className="text-3xl font-black">Blog</h1>
71+
<a
72+
href="/rss.xml"
73+
target="_blank"
74+
rel="noreferrer"
75+
className="text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors text-xl"
76+
title="RSS Feed"
77+
>
78+
<RssIcon />
79+
</a>
80+
</div>
81+
6982
<p className="text-lg mt-4 text-gray-600 dark:text-gray-400">
7083
The latest news and blog posts from TanStack
7184
</p>

src/routes/rss[.]xml.ts

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

54
function escapeXml(unsafe: string): string {
65
return unsafe
@@ -11,7 +10,9 @@ function escapeXml(unsafe: string): string {
1110
.replace(/'/g, '&apos;')
1211
}
1312

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

3637
return `
@@ -61,11 +62,11 @@ function generateRSSFeed() {
6162
}
6263

6364
export const Route = createFileRoute('/rss.xml')({
64-
// @ts-ignore server property not in route types yet
65+
// @ts-expect-error server property not in route types yet
6566
server: {
6667
handlers: {
6768
GET: async () => {
68-
const content = generateRSSFeed()
69+
const content = await generateRSSFeed()
6970

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

0 commit comments

Comments
 (0)