From 9e00b021f622ca6bd1df355dc68f866e0ea017f6 Mon Sep 17 00:00:00 2001 From: prototypa Date: Wed, 17 Aug 2022 22:37:38 -0400 Subject: [PATCH] Add RSS support --- package.json | 3 +++ src/pages/rss.xml.js | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/pages/rss.xml.js diff --git a/package.json b/package.json index 969ba71..b36b186 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,14 @@ }, "devDependencies": { "@astrojs/image": "^0.3.3", + "@astrojs/rss": "^1.0.0", "@astrojs/sitemap": "^1.0.0", "@astrojs/tailwind": "^1.0.0", + "@tailwindcss/typography": "^0.5.4", "astro": "^1.0.0", "prettier": "^2.7.1", "prettier-plugin-astro": "^0.5.0", + "reading-time": "^1.5.0", "subfont": "^6.9.0" } } diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js new file mode 100644 index 0000000..f641f18 --- /dev/null +++ b/src/pages/rss.xml.js @@ -0,0 +1,20 @@ +import rss from "@astrojs/rss"; + +import { SITE } from "~/config"; +import { getAllPosts } from "~/utils/getAllPosts"; + +const posts = await getAllPosts(); + +export const get = () => + rss({ + title: `${SITE.name}’s Blog`, + description: + "A ready to start template to make your website using Astro and Tailwind CSS.", + site: import.meta.env.SITE, + items: posts.map((post) => ({ + link: `blog/${post.slug}`, + title: post.title, + description: post.description, + pubDate: post.pubDate, + })), + });