mirror of
https://github.com/anotherhadi/blog.git
synced 2026-04-02 11:42:10 +02:00
add rss feed
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -63,6 +63,14 @@ const origin = Astro.url.origin;
|
||||
<meta name="twitter:title" content={title} />
|
||||
<meta name="twitter:description" content={description} />
|
||||
<meta name="twitter:image" content={`${origin}/images/og_home.png`} />
|
||||
|
||||
<!-- RSS Feed -->
|
||||
<link
|
||||
rel="alternate"
|
||||
type="application/rss+xml"
|
||||
title="Another Hadi RSS Feed"
|
||||
href="/rss.xml"
|
||||
/>
|
||||
</head>
|
||||
<body class="min-h-screen">
|
||||
<slot />
|
||||
|
||||
35
src/pages/rss.xml.ts
Normal file
35
src/pages/rss.xml.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import rss from "@astrojs/rss";
|
||||
import { getCollection } from "astro:content";
|
||||
import type { APIContext } from "astro";
|
||||
|
||||
export async function GET(context: APIContext) {
|
||||
const blog = await getCollection("blog");
|
||||
const projects = await getCollection("projects");
|
||||
|
||||
const blogItems = blog.map((post) => ({
|
||||
title: post.data.title,
|
||||
pubDate: post.data.publishDate,
|
||||
description: post.data.description,
|
||||
link: `/blog/${post.id}/`,
|
||||
}));
|
||||
|
||||
const projectItems = projects.map((project) => ({
|
||||
title: `[Project] ${project.data.title}`,
|
||||
pubDate: new Date(),
|
||||
description: project.data.description,
|
||||
link: `/projects/${project.id}/`,
|
||||
}));
|
||||
|
||||
const allItems = [...blogItems, ...projectItems].sort(
|
||||
(a, b) => b.pubDate.getTime() - a.pubDate.getTime(),
|
||||
);
|
||||
|
||||
return rss({
|
||||
title: "Another Hadi",
|
||||
description:
|
||||
"Thoughts, insights, and tutorials on cybersecurity, OSINT, and technology.",
|
||||
site: context.site!,
|
||||
items: allItems,
|
||||
customData: `<language>en</language>`,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user