diff options
author | 2023-01-18 08:43:58 -0500 | |
---|---|---|
committer | 2023-01-18 08:43:58 -0500 | |
commit | 7d72aeeae8c867af2ae6c018611e39c184f50619 (patch) | |
tree | 93015c571dc820db3e37e8eba93455014a048d7e /examples/blog/src/pages/rss.xml.js | |
parent | 006405d33c2b8eb1307cb84161659428e43efa51 (diff) | |
download | astro-7d72aeeae8c867af2ae6c018611e39c184f50619.tar.gz astro-7d72aeeae8c867af2ae6c018611e39c184f50619.tar.zst astro-7d72aeeae8c867af2ae6c018611e39c184f50619.zip |
Migrate blog and docs starters to content collections (#5858)
* docs: update README for `content/`
* chore: update env
* feat: update blog to use content collections
* chore: remove with-content starter
* fix: single quotes -> double
* feat: update docs starter to content collections
* refactor: config -> consts
* chore: import type
* edit: Astro will -> Use
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* chore: remove unused null check
* nit: spacing
* nit: `as Props` 1
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* nit: `as Props` 2
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* chore: consistent CONSTS usage
* chore: `type` imports at top
* chore: consistent quote usage on YAML
* chore: remove `as Props` from docs
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'examples/blog/src/pages/rss.xml.js')
-rw-r--r-- | examples/blog/src/pages/rss.xml.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/examples/blog/src/pages/rss.xml.js b/examples/blog/src/pages/rss.xml.js index 4e6ed73c4..3997cc45e 100644 --- a/examples/blog/src/pages/rss.xml.js +++ b/examples/blog/src/pages/rss.xml.js @@ -1,10 +1,16 @@ import rss from '@astrojs/rss'; -import { SITE_TITLE, SITE_DESCRIPTION } from '../config'; +import { getCollection } from 'astro:content'; +import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'; -export const get = () => - rss({ +export async function get(context) { + const posts = await getCollection('blog'); + return rss({ title: SITE_TITLE, description: SITE_DESCRIPTION, - site: import.meta.env.SITE, - items: import.meta.glob('./blog/**/*.{md,mdx}'), + site: context.site.href, + items: posts.map((post) => ({ + ...post.data, + link: `/blog/${post.slug}/`, + })), }); +} |