feat: create separated rss feeds
All checks were successful
Docker / build-and-push-image (push) Successful in 2m11s
All checks were successful
Docker / build-and-push-image (push) Successful in 2m11s
This commit is contained in:
parent
4f9ebdcc66
commit
782bfc7c90
10 changed files with 86 additions and 6 deletions
|
@ -46,7 +46,23 @@ if (typeof tags !== "undefined") {
|
||||||
rel="alternate"
|
rel="alternate"
|
||||||
type="application/rss+xml"
|
type="application/rss+xml"
|
||||||
title={SITE.TITLE}
|
title={SITE.TITLE}
|
||||||
href="/rss.xml"
|
href="/feed.xml"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<link
|
||||||
|
rel="alternate"
|
||||||
|
type="application/rss+xml"
|
||||||
|
title=`${SITE.TITLE} Projects`
|
||||||
|
href="/projects.xml"
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<link
|
||||||
|
rel="alternate"
|
||||||
|
type="application/rss+xml"
|
||||||
|
title=`${SITE.TITLE} Posts`
|
||||||
|
href="/posts.xml"
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ const { collection } = Astro.props;
|
||||||
>
|
>
|
||||||
<article class="flex flex-col">
|
<article class="flex flex-col">
|
||||||
<div class="flex flex-col justify-between md:flex-row md:items-center">
|
<div class="flex flex-col justify-between md:flex-row md:items-center">
|
||||||
<h3 class="text-secondary mb-1 text-lg font-semibold text-nowrap">
|
<h3
|
||||||
|
class="text-secondary group-hover:text-tertiary mb-1 text-lg font-semibold text-nowrap transition-colors duration-300"
|
||||||
|
>
|
||||||
{collection.data.title}
|
{collection.data.title}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="text-tertiary flex items-center gap-2">
|
<div class="text-tertiary flex items-center gap-2">
|
||||||
|
|
|
@ -25,7 +25,7 @@ const { collection } = Astro.props;
|
||||||
<div
|
<div
|
||||||
class="relative opacity-0 transition-all delay-100 duration-300 ease-in-out group-hover:opacity-100"
|
class="relative opacity-0 transition-all delay-100 duration-300 ease-in-out group-hover:opacity-100"
|
||||||
>
|
>
|
||||||
<p class="absolute right-5 bottom-5 font-medium">
|
<p class="absolute right-5 bottom-5 font-medium text-white">
|
||||||
{collection.data.title}
|
{collection.data.title}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -32,7 +32,7 @@ const { interval = 3000, images } = Astro.props;
|
||||||
loading="eager"
|
loading="eager"
|
||||||
/>
|
/>
|
||||||
<div class="relative opacity-0 transition-all delay-100 duration-300 ease-in-out group-hover:opacity-100">
|
<div class="relative opacity-0 transition-all delay-100 duration-300 ease-in-out group-hover:opacity-100">
|
||||||
<p class="absolute right-5 bottom-5 font-medium">
|
<p class="absolute right-5 bottom-5 font-medium text-white">
|
||||||
{image.data.title}
|
{image.data.title}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,8 +25,8 @@ export const SITE: Site = {
|
||||||
AUTHOR: "Troy Lusty",
|
AUTHOR: "Troy Lusty",
|
||||||
LINKS: [
|
LINKS: [
|
||||||
{
|
{
|
||||||
name: "RSS",
|
name: "RSS Feed",
|
||||||
href: "/rss.xml",
|
href: "/feed.xml",
|
||||||
icon: "mdi:rss",
|
icon: "mdi:rss",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
23
src/pages/posts.xml.ts
Normal file
23
src/pages/posts.xml.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import rss from "@astrojs/rss";
|
||||||
|
import { SITE } from "@consts";
|
||||||
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
|
export async function GET(context: { site: string }) {
|
||||||
|
const posts = (await getCollection("posts"))
|
||||||
|
.filter((post) => !post.data.draft)
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
|
||||||
|
);
|
||||||
|
return rss({
|
||||||
|
title: `${SITE.TITLE} Posts`,
|
||||||
|
description: SITE.DESCRIPTION,
|
||||||
|
site: context.site,
|
||||||
|
items: posts.map((item) => ({
|
||||||
|
title: item.data.title,
|
||||||
|
description: item.data.description,
|
||||||
|
pubDate: item.data.date,
|
||||||
|
link: `/${item.collection}/${item.slug}/`,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { getCollection } from "astro:content";
|
||||||
import { SITE, POSTS } from "@consts";
|
import { SITE, POSTS } from "@consts";
|
||||||
import ShowcasePost from "@components/ShowcasePost.astro";
|
import ShowcasePost from "@components/ShowcasePost.astro";
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
|
import Link from "@components/Link.astro";
|
||||||
|
|
||||||
const posts = (await getCollection("posts"))
|
const posts = (await getCollection("posts"))
|
||||||
.filter((post) => !post.data.draft)
|
.filter((post) => !post.data.draft)
|
||||||
|
@ -22,4 +23,11 @@ const posts = (await getCollection("posts"))
|
||||||
posts.map((article: any) => <ShowcasePost collection={article} />)
|
posts.map((article: any) => <ShowcasePost collection={article} />)
|
||||||
}
|
}
|
||||||
</ol>
|
</ol>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<Link
|
||||||
|
href="/posts.xml"
|
||||||
|
class="text-tertiary hover:text-secondary text-xs transition-colors duration-300"
|
||||||
|
>View posts feed</Link
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
23
src/pages/projects.xml.ts
Normal file
23
src/pages/projects.xml.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import rss from "@astrojs/rss";
|
||||||
|
import { SITE } from "@consts";
|
||||||
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
|
export async function GET(context: { site: string }) {
|
||||||
|
const projects = (await getCollection("projects"))
|
||||||
|
.filter((project) => !project.data.draft)
|
||||||
|
.sort(
|
||||||
|
(a, b) =>
|
||||||
|
new Date(b.data.date).valueOf() - new Date(a.data.date).valueOf(),
|
||||||
|
);
|
||||||
|
return rss({
|
||||||
|
title: `${SITE.TITLE} Projects`,
|
||||||
|
description: SITE.DESCRIPTION,
|
||||||
|
site: context.site,
|
||||||
|
items: projects.map((item) => ({
|
||||||
|
title: item.data.title,
|
||||||
|
description: item.data.description,
|
||||||
|
pubDate: item.data.date,
|
||||||
|
link: `/${item.collection}/${item.slug}/`,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { getCollection } from "astro:content";
|
||||||
import { PROJECTS, SITE } from "@consts";
|
import { PROJECTS, SITE } from "@consts";
|
||||||
import Layout from "@layouts/Layout.astro";
|
import Layout from "@layouts/Layout.astro";
|
||||||
import ShowcaseProject from "@components/ShowcaseProject.astro";
|
import ShowcaseProject from "@components/ShowcaseProject.astro";
|
||||||
|
import Link from "@components/Link.astro";
|
||||||
|
|
||||||
const projects = (await getCollection("projects"))
|
const projects = (await getCollection("projects"))
|
||||||
.filter((project) => !project.data.draft)
|
.filter((project) => !project.data.draft)
|
||||||
|
@ -18,4 +19,11 @@ const projects = (await getCollection("projects"))
|
||||||
>
|
>
|
||||||
{projects.map((article: any) => <ShowcaseProject collection={article} />)}
|
{projects.map((article: any) => <ShowcaseProject collection={article} />)}
|
||||||
</ol>
|
</ol>
|
||||||
|
<div class="flex justify-end">
|
||||||
|
<Link
|
||||||
|
href="/projects.xml"
|
||||||
|
class="text-tertiary hover:text-secondary text-xs transition-colors duration-300"
|
||||||
|
>View projects feed</Link
|
||||||
|
>
|
||||||
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue