Skip to content

Commit

Permalink
RSS: FIx Feed and URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tordans committed Sep 6, 2024
1 parent d33f549 commit 5a6b79a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export default defineConfig({
},
vite: {
ssr: { noExternal: ['route-snapper'] },
optimizeDeps: {
exclude: ['route-snapper'],
},
optimizeDeps: { exclude: ['route-snapper'] },
plugins: [
// See keystatic/scripts/README.md
watchAndRun([
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const noindex = project.enabled === false || contentNoindex
<meta name="theme-color" content="#7D5197" />
<meta name="generator" content={Astro.generator} data-generated-at={new Date().toISOString()} />

<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="feed.xml" />
<link rel="alternate" type="application/rss+xml" href="feed.xml" />

<!-- TODO: Check out https://npm.io/package/tailwindcss-safe-area as a possible alternative -->
<script is:inline is:raw>
Expand Down
12 changes: 7 additions & 5 deletions src/pages/feed.xml.js → src/pages/feed.xml.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import rss from '@astrojs/rss'
import { getProjects } from '@layouts/utils/getProjects'
import type { APIContext } from 'astro'
import { getCollection } from 'astro:content'

export async function get(context) {
export async function GET(context: APIContext) {
const projects = await getProjects()
const rootProject = projects.find((p) => p.name.slug === 'root')
const rootProject = projects.find((p) => p.name.slug === 'root')!

const posts = await getCollection('posts')

return rss({
title: rootProject.meta.title,
description: rootProject.meta.description,
site: context.site,
description: rootProject.meta.description ?? '',
site: context.site!,
items: posts.map((post) => ({
...post.data,
link: `/posts/${post.slug}/`,
link: `${post.data.project}/posts/${post.slug}/`,
customData: `<language>${post.data.language || 'de'}</language>`,
})),
})
}

0 comments on commit 5a6b79a

Please sign in to comment.