Skip to content

Commit 7e6bb28

Browse files
feat: add RSS feed link to header and footer, enhance RSS feed item structure
1 parent bda1c4f commit 7e6bb28

File tree

4 files changed

+56
-10
lines changed

4 files changed

+56
-10
lines changed

rss.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<svg fill="#000000" width="64px" height="64px" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg">
2+
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
3+
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
4+
<g id="SVGRepo_iconCarrier">
5+
<path d="M53.333 628.96c682.454 0 1237.76 555.2 1237.76 1237.76v53.333H882.24v-53.333c0-457.067-371.84-828.907-828.907-828.907H0V628.96Zm0-628.96C1082.56 0 1920 837.44 1920 1866.667V1920h-408.853v-53.333c0-803.84-653.974-1457.814-1457.814-1457.814H0V0ZM267.19 1386.667c146.774 0 266.134 119.36 266.134 266.133 0 146.773-119.36 266.24-266.134 266.24S.95 1799.573.95 1652.8c0-146.773 119.467-266.133 266.24-266.133Z" fill-rule="evenodd"></path>
6+
</g>
7+
</svg>

src/components/Footer.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ const today = new Date();
2424
<path fill="currentColor" d="M32 6C17.641 6 6 17.641 6 32c0 12.277 8.512 22.56 19.955 25.286-.592-.141-1.179-.299-1.755-.479V50.85c0 0-.975.325-2.275.325-3.637 0-5.148-3.245-5.525-4.875-.229-.993-.827-1.934-1.469-2.509-.767-.684-1.126-.686-1.131-.92-.01-.491.658-.471.975-.471 1.625 0 2.857 1.729 3.429 2.623 1.417 2.207 2.938 2.577 3.721 2.577.975 0 1.817-.146 2.397-.426.268-1.888 1.108-3.57 2.478-4.774-6.097-1.219-10.4-4.716-10.4-10.4 0-2.928 1.175-5.619 3.133-7.792C19.333 23.641 19 22.494 19 20.625c0-1.235.086-2.751.65-4.225 0 0 3.708.026 7.205 3.338C28.469 19.268 30.196 19 32 19s3.531.268 5.145.738c3.497-3.312 7.205-3.338 7.205-3.338.567 1.474.65 2.99.65 4.225 0 2.015-.268 3.19-.432 3.697C46.466 26.475 47.6 29.124 47.6 32c0 5.684-4.303 9.181-10.4 10.4 1.628 1.43 2.6 3.513 2.6 5.85v8.557c-.576.181-1.162.338-1.755.479C49.488 54.56 58 44.277 58 32 58 17.641 46.359 6 32 6zM33.813 57.93C33.214 57.972 32.61 58 32 58 32.61 58 33.213 57.971 33.813 57.93zM37.786 57.346c-1.164.265-2.357.451-3.575.554C35.429 57.797 36.622 57.61 37.786 57.346zM32 58c-.61 0-1.214-.028-1.813-.07C30.787 57.971 31.39 58 32 58zM29.788 57.9c-1.217-.103-2.411-.289-3.574-.554C27.378 57.61 28.571 57.797 29.788 57.9z"></path>
2525
</svg>
2626
</a>
27+
<a href="https://nicholasdbrady.github.io/cookbook/rss.xml"target="_blank" rel="noopener noreferrer" aria-label="RSS Feed" >
28+
<span class="sr-only">RSS Feed</span>
29+
<svg fill="#000000" width="32" height="32" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg">
30+
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
31+
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
32+
<g id="SVGRepo_iconCarrier">
33+
<path d="M53.333 628.96c682.454 0 1237.76 555.2 1237.76 1237.76v53.333H882.24v-53.333c0-457.067-371.84-828.907-828.907-828.907H0V628.96Zm0-628.96C1082.56 0 1920 837.44 1920 1866.667V1920h-408.853v-53.333c0-803.84-653.974-1457.814-1457.814-1457.814H0V0ZM267.19 1386.667c146.774 0 266.134 119.36 266.134 266.133 0 146.773-119.36 266.24-266.134 266.24S.95 1799.573.95 1652.8c0-146.773 119.467-266.133 266.24-266.133Z" fill-rule="evenodd"></path>
34+
</g>
35+
</svg>
36+
</a>
2737
</div>
2838
</footer>
2939
<style>

src/components/Header.astro

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ import { SITE_TITLE } from '../consts';
3131
<path fill="currentColor" d="M32 6C17.641 6 6 17.641 6 32c0 12.277 8.512 22.56 19.955 25.286-.592-.141-1.179-.299-1.755-.479V50.85c0 0-.975.325-2.275.325-3.637 0-5.148-3.245-5.525-4.875-.229-.993-.827-1.934-1.469-2.509-.767-.684-1.126-.686-1.131-.92-.01-.491.658-.471.975-.471 1.625 0 2.857 1.729 3.429 2.623 1.417 2.207 2.938 2.577 3.721 2.577.975 0 1.817-.146 2.397-.426.268-1.888 1.108-3.57 2.478-4.774-6.097-1.219-10.4-4.716-10.4-10.4 0-2.928 1.175-5.619 3.133-7.792C19.333 23.641 19 22.494 19 20.625c0-1.235.086-2.751.65-4.225 0 0 3.708.026 7.205 3.338C28.469 19.268 30.196 19 32 19s3.531.268 5.145.738c3.497-3.312 7.205-3.338 7.205-3.338.567 1.474.65 2.99.65 4.225 0 2.015-.268 3.19-.432 3.697C46.466 26.475 47.6 29.124 47.6 32c0 5.684-4.303 9.181-10.4 10.4 1.628 1.43 2.6 3.513 2.6 5.85v8.557c-.576.181-1.162.338-1.755.479C49.488 54.56 58 44.277 58 32 58 17.641 46.359 6 32 6zM33.813 57.93C33.214 57.972 32.61 58 32 58 32.61 58 33.213 57.971 33.813 57.93zM37.786 57.346c-1.164.265-2.357.451-3.575.554C35.429 57.797 36.622 57.61 37.786 57.346zM32 58c-.61 0-1.214-.028-1.813-.07C30.787 57.971 31.39 58 32 58zM29.788 57.9c-1.217-.103-2.411-.289-3.574-.554C27.378 57.61 28.571 57.797 29.788 57.9z"></path>
3232
</svg>
3333
</a>
34+
<a href="https://nicholasdbrady.github.io/cookbook/rss.xml"target="_blank" rel="noopener noreferrer" aria-label="RSS Feed" >
35+
<span class="sr-only">RSS Feed</span>
36+
<svg fill="#000000" width="32" height="32" viewBox="0 0 1920 1920" xmlns="http://www.w3.org/2000/svg">
37+
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
38+
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
39+
<g id="SVGRepo_iconCarrier">
40+
<path d="M53.333 628.96c682.454 0 1237.76 555.2 1237.76 1237.76v53.333H882.24v-53.333c0-457.067-371.84-828.907-828.907-828.907H0V628.96Zm0-628.96C1082.56 0 1920 837.44 1920 1866.667V1920h-408.853v-53.333c0-803.84-653.974-1457.814-1457.814-1457.814H0V0ZM267.19 1386.667c146.774 0 266.134 119.36 266.134 266.133 0 146.773-119.36 266.24-266.134 266.24S.95 1799.573.95 1652.8c0-146.773 119.467-266.133 266.24-266.133Z" fill-rule="evenodd"></path>
41+
</g>
42+
</svg>
43+
</a>
3444
</div>
3545
</nav>
3646
</header>

src/pages/rss.xml.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,33 @@ import { getCollection } from 'astro:content';
33
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
44

55
export async function GET(context) {
6-
const posts = await getCollection('blog');
7-
return rss({
8-
title: SITE_TITLE,
9-
description: SITE_DESCRIPTION,
10-
site: context.site,
11-
items: posts.map((post) => ({
12-
...post.data,
13-
link: `/blog/${post.slug}/`,
14-
})),
15-
});
6+
// Retrieve all published blog posts from the "blog" collection
7+
const posts = await getCollection('blog', ({ data }) => !data.draft);
8+
9+
// Map each post to an RSS feed item.
10+
// Here we include the full content from the post body.
11+
// (If you need to render Markdown to HTML, you may use post.render() with appropriate rendering logic.)
12+
const items = posts.map((post) => ({
13+
title: post.data.title,
14+
// Link to the blog post page; adjust if your routing differs.
15+
link: `/blog/${post.slug}/`,
16+
// Publication date from frontmatter
17+
pubDate: post.data.pubDate,
18+
// A short summary/description for the feed item
19+
description: post.data.description,
20+
// Full post content – note that post.body is the raw Markdown.
21+
// For proper HTML, ensure your collection loader converts it, or use post.render() to generate HTML.
22+
content: post.body,
23+
// Optional: add categories if available
24+
categories: post.data.tags || [],
25+
// Optionally, include the author field if present
26+
author: post.data.author || undefined,
27+
}));
28+
29+
return rss({
30+
title: SITE_TITLE,
31+
description: SITE_DESCRIPTION,
32+
site: context.site,
33+
items,
34+
});
1635
}

0 commit comments

Comments
 (0)