diff --git a/src/components/Head.astro b/src/components/Head.astro index dd3ea90..9690c0e 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -46,7 +46,23 @@ if (typeof tags !== "undefined") { rel="alternate" type="application/rss+xml" title={SITE.TITLE} - href="/rss.xml" + href="/feed.xml" + } + /> + + + + diff --git a/src/components/ShowcasePost.astro b/src/components/ShowcasePost.astro index 1ec952e..b0595fe 100644 --- a/src/components/ShowcasePost.astro +++ b/src/components/ShowcasePost.astro @@ -17,7 +17,9 @@ const { collection } = Astro.props; >
-

+

{collection.data.title}

diff --git a/src/components/ShowcaseProject.astro b/src/components/ShowcaseProject.astro index 2032397..231e703 100644 --- a/src/components/ShowcaseProject.astro +++ b/src/components/ShowcaseProject.astro @@ -25,7 +25,7 @@ const { collection } = Astro.props;
-

+

{collection.data.title}

diff --git a/src/components/Slideshow.astro b/src/components/Slideshow.astro index 3a2133c..df7439d 100644 --- a/src/components/Slideshow.astro +++ b/src/components/Slideshow.astro @@ -32,7 +32,7 @@ const { interval = 3000, images } = Astro.props; loading="eager" />
-

+

{image.data.title}

diff --git a/src/consts.ts b/src/consts.ts index 78bf0e1..5b2efe6 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -25,8 +25,8 @@ export const SITE: Site = { AUTHOR: "Troy Lusty", LINKS: [ { - name: "RSS", - href: "/rss.xml", + name: "RSS Feed", + href: "/feed.xml", icon: "mdi:rss", }, { diff --git a/src/pages/rss.xml.ts b/src/pages/feed.xml.ts similarity index 100% rename from src/pages/rss.xml.ts rename to src/pages/feed.xml.ts diff --git a/src/pages/posts.xml.ts b/src/pages/posts.xml.ts new file mode 100644 index 0000000..d7b7a66 --- /dev/null +++ b/src/pages/posts.xml.ts @@ -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}/`, + })), + }); +} diff --git a/src/pages/posts/index.astro b/src/pages/posts/index.astro index 1d119e2..4bd570c 100644 --- a/src/pages/posts/index.astro +++ b/src/pages/posts/index.astro @@ -3,6 +3,7 @@ import { getCollection } from "astro:content"; import { SITE, POSTS } from "@consts"; import ShowcasePost from "@components/ShowcasePost.astro"; import Layout from "@layouts/Layout.astro"; +import Link from "@components/Link.astro"; const posts = (await getCollection("posts")) .filter((post) => !post.data.draft) @@ -22,4 +23,11 @@ const posts = (await getCollection("posts")) posts.map((article: any) => ) } +
+ View posts feed +
diff --git a/src/pages/projects.xml.ts b/src/pages/projects.xml.ts new file mode 100644 index 0000000..f1ac5ff --- /dev/null +++ b/src/pages/projects.xml.ts @@ -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}/`, + })), + }); +} diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro index 6132c51..18e0767 100644 --- a/src/pages/projects/index.astro +++ b/src/pages/projects/index.astro @@ -3,6 +3,7 @@ import { getCollection } from "astro:content"; import { PROJECTS, SITE } from "@consts"; import Layout from "@layouts/Layout.astro"; import ShowcaseProject from "@components/ShowcaseProject.astro"; +import Link from "@components/Link.astro"; const projects = (await getCollection("projects")) .filter((project) => !project.data.draft) @@ -18,4 +19,11 @@ const projects = (await getCollection("projects")) > {projects.map((article: any) => )} +
+ View projects feed +