mirror of
https://github.com/anotherhadi/blog.git
synced 2026-04-02 11:42:10 +02:00
Add RSS Feed button
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
import { ArrowRight, Coffee, FolderCode, Key, Newspaper } from "@lucide/astro";
|
import { ArrowRight, Coffee, FolderCode, Key, Newspaper } from "@lucide/astro";
|
||||||
import { Image } from "astro:assets";
|
import { Image } from "astro:assets";
|
||||||
|
import { Rss } from "lucide-astro";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -22,9 +23,10 @@ interface Props {
|
|||||||
codetips?: string;
|
codetips?: string;
|
||||||
};
|
};
|
||||||
gpgKey?: string;
|
gpgKey?: string;
|
||||||
|
rssFeed?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { name, title, description, avatar, location, socialLinks, gpgKey } =
|
const { name, title, description, avatar, location, socialLinks, gpgKey, rssFeed } =
|
||||||
Astro.props;
|
Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -316,6 +318,18 @@ const { name, title, description, avatar, location, socialLinks, gpgKey } =
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{rssFeed && (
|
||||||
|
<div class="tooltip" data-tip="RSS Feed">
|
||||||
|
<a
|
||||||
|
href={rssFeed}
|
||||||
|
class="btn btn-circle btn-ghost"
|
||||||
|
aria-label="RSS Feed"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<Rss class="size-6" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export interface SiteConfig {
|
|||||||
location: string;
|
location: string;
|
||||||
socialLinks: SocialLinks;
|
socialLinks: SocialLinks;
|
||||||
gpgKey?: string;
|
gpgKey?: string;
|
||||||
|
rssFeed?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +35,7 @@ export interface SiteConfig {
|
|||||||
*/
|
*/
|
||||||
export const siteConfig: SiteConfig = {
|
export const siteConfig: SiteConfig = {
|
||||||
name: "Hadi",
|
name: "Hadi",
|
||||||
title: "Infosec engineer.",
|
title: "@anotherhadi - Infosec engineer.",
|
||||||
description:
|
description:
|
||||||
"Infosec engineer passionate about Linux/NixOS, blockchains, OSINT & FOSS. Hacking with Go, exploring open tech, and contributing whenever I can 🐧",
|
"Infosec engineer passionate about Linux/NixOS, blockchains, OSINT & FOSS. Hacking with Go, exploring open tech, and contributing whenever I can 🐧",
|
||||||
avatar: "/avatar.png",
|
avatar: "/avatar.png",
|
||||||
@@ -49,4 +50,5 @@ export const siteConfig: SiteConfig = {
|
|||||||
medium: "https://medium.com/@anotherhadi",
|
medium: "https://medium.com/@anotherhadi",
|
||||||
},
|
},
|
||||||
gpgKey: "/anotherhadi.asc",
|
gpgKey: "/anotherhadi.asc",
|
||||||
|
rssFeed: "https://hadi.icu/rss.xml",
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
import Layout from "../../layouts/Layout.astro";
|
import Layout from "../../layouts/Layout.astro";
|
||||||
import { getCollection } from "astro:content";
|
import { getCollection } from "astro:content";
|
||||||
import { Image } from "astro:assets";
|
|
||||||
import TagBadge from "../../components/TagBadge.astro";
|
|
||||||
import { ChevronLeft } from "@lucide/astro";
|
import { ChevronLeft } from "@lucide/astro";
|
||||||
import BlogCard from "../../components/BlogCard.astro";
|
import BlogCard from "../../components/BlogCard.astro";
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import avatar from "../../public/avatar.jpg";
|
|||||||
location={siteConfig.location}
|
location={siteConfig.location}
|
||||||
socialLinks={siteConfig.socialLinks}
|
socialLinks={siteConfig.socialLinks}
|
||||||
gpgKey={siteConfig.gpgKey}
|
gpgKey={siteConfig.gpgKey}
|
||||||
|
rssFeed={siteConfig.rssFeed}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Blog />
|
<Blog />
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import type { APIContext } from "astro";
|
|||||||
|
|
||||||
export async function GET(context: APIContext) {
|
export async function GET(context: APIContext) {
|
||||||
const blog = await getCollection("blog");
|
const blog = await getCollection("blog");
|
||||||
const projects = await getCollection("projects");
|
|
||||||
|
|
||||||
const blogItems = blog.map((post) => ({
|
const blogItems = blog.map((post) => ({
|
||||||
title: post.data.title,
|
title: post.data.title,
|
||||||
@@ -18,24 +17,12 @@ export async function GET(context: APIContext) {
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const projectItems = projects.map((project) => ({
|
const allItems = [...blogItems].sort(
|
||||||
title: `[Project] ${project.data.title}`,
|
|
||||||
pubDate: new Date(),
|
|
||||||
description: project.data.description,
|
|
||||||
link: `/projects/${project.id}/`,
|
|
||||||
enclosure: {
|
|
||||||
url: new URL(project.data.image.src, context.site).toString(),
|
|
||||||
length: 0,
|
|
||||||
type: "image/png",
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const allItems = [...blogItems, ...projectItems].sort(
|
|
||||||
(a, b) => b.pubDate.getTime() - a.pubDate.getTime(),
|
(a, b) => b.pubDate.getTime() - a.pubDate.getTime(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
title: "Another Hadi",
|
title: "Another Hadi - Blog posts",
|
||||||
description:
|
description:
|
||||||
"Thoughts, insights, and tutorials on cybersecurity, OSINT, and technology.",
|
"Thoughts, insights, and tutorials on cybersecurity, OSINT, and technology.",
|
||||||
site: context.site!,
|
site: context.site!,
|
||||||
|
|||||||
Reference in New Issue
Block a user