fix: add posts to rss.xml

This commit is contained in:
Sean McPherson
2022-12-19 06:49:28 -05:00
parent 2b5008fce9
commit cd303a03a6
4 changed files with 23 additions and 9 deletions

14
package-lock.json generated
View File

@@ -8,7 +8,7 @@
"name": "@example/blog",
"version": "0.0.1",
"devDependencies": {
"@astrojs/rss": "^1.0.3",
"@astrojs/rss": "^1.2.1",
"@astrojs/sitemap": "^1.0.0",
"astro": "^1.6.11",
"esbuild": "^0.15.12",
@@ -136,9 +136,9 @@
}
},
"node_modules/@astrojs/rss": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-1.0.3.tgz",
"integrity": "sha512-SkAUMnp/LpryOR5B69rlF69AjKE3YlIPRmWad5WoRVeAH1CEEvSh8sC8/qhtG9haPFYa9JoX6zp5V5MkUOop3A==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-1.2.1.tgz",
"integrity": "sha512-ZgCunS6ECuPpxBznBYE+ONf23rcp+OWZ5IyDKFAcVZCWEq8Bh0rVYa9p8u6cU9WOTK56JRQTuwcVZYndmExNtw==",
"dev": true,
"dependencies": {
"fast-xml-parser": "^4.0.8"
@@ -7069,9 +7069,9 @@
}
},
"@astrojs/rss": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-1.0.3.tgz",
"integrity": "sha512-SkAUMnp/LpryOR5B69rlF69AjKE3YlIPRmWad5WoRVeAH1CEEvSh8sC8/qhtG9haPFYa9JoX6zp5V5MkUOop3A==",
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@astrojs/rss/-/rss-1.2.1.tgz",
"integrity": "sha512-ZgCunS6ECuPpxBznBYE+ONf23rcp+OWZ5IyDKFAcVZCWEq8Bh0rVYa9p8u6cU9WOTK56JRQTuwcVZYndmExNtw==",
"dev": true,
"requires": {
"fast-xml-parser": "^4.0.8"

View File

@@ -10,7 +10,7 @@
"astro": "astro"
},
"devDependencies": {
"@astrojs/rss": "^1.0.3",
"@astrojs/rss": "^1.2.1",
"@astrojs/sitemap": "^1.0.0",
"astro": "^1.6.11",
"esbuild": "^0.15.12",

View File

@@ -1,6 +1,8 @@
---
import "../style/global.css";
import { SITE_TITLE } from "../config"
const { title, description, image = "/home-blog-card.png" } = Astro.props;
---
@@ -38,4 +40,7 @@ const { title, description, image = "/home-blog-card.png" } = Astro.props;
href="https://fonts.googleapis.com/css?family=Roboto+Mono"
rel="stylesheet"
/>
<!-- RSS Link -->
<link rel="alternate" href="/rss.xml" type="application/rss+xml" title={SITE_TITLE}>
</head>

View File

@@ -1,10 +1,19 @@
import rss from "@astrojs/rss";
import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
const posts = Object.values(import.meta.glob("../posts/*.md", { eager: true }));
export const get = () =>
rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: import.meta.env.SITE,
items: import.meta.glob("./blog/**/*.md"),
items: posts.map((post) => {
return {
link: `/post/${post.frontmatter.slug}`,
title: post.frontmatter.title,
pubDate: post.frontmatter.added,
content: post.compiledContent(),
};
}),
});