Merge pull request #4 from SeanMcP/main

fix: add posts to rss.xml
This commit is contained in:
Cassidy Williams
2022-12-19 22:54:26 -06:00
committed by GitHub
4 changed files with 23 additions and 9 deletions

14
package-lock.json generated
View File

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

View File

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

View File

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

View File

@@ -1,10 +1,19 @@
import rss from "@astrojs/rss"; import rss from "@astrojs/rss";
import { SITE_TITLE, SITE_DESCRIPTION } from "../config"; import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
const posts = Object.values(import.meta.glob("../posts/*.md", { eager: true }));
export const get = () => export const get = () =>
rss({ rss({
title: SITE_TITLE, title: SITE_TITLE,
description: SITE_DESCRIPTION, description: SITE_DESCRIPTION,
site: import.meta.env.SITE, 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(),
};
}),
}); });