From d03d30aa7678e9aee84094ae96c522ca74d265b8 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 27 Feb 2025 23:59:14 -0600 Subject: [PATCH] feat: improve blog page design and add RSS feed support --- .../website/app/[locale]/blog/[slug]/page.tsx | 17 ++-- apps/website/app/[locale]/blog/page.tsx | 84 +++++++++++-------- apps/website/app/rss.xml/route.ts | 46 ++++++++++ 3 files changed, 103 insertions(+), 44 deletions(-) create mode 100644 apps/website/app/rss.xml/route.ts diff --git a/apps/website/app/[locale]/blog/[slug]/page.tsx b/apps/website/app/[locale]/blog/[slug]/page.tsx index 92f0a66..2bbef31 100644 --- a/apps/website/app/[locale]/blog/[slug]/page.tsx +++ b/apps/website/app/[locale]/blog/[slug]/page.tsx @@ -74,21 +74,24 @@ export default async function BlogPostPage({ params }: Props) { const components: Partial = { h1: ({ node, ...props }) => ( -

+

), h2: ({ node, ...props }) => ( -

+

), h3: ({ node, ...props }) => ( -

+

), p: ({ node, ...props }) => ( -

+

), a: ({ node, href, ...props }) => ( +

-
+

{post.title}

diff --git a/apps/website/app/[locale]/blog/page.tsx b/apps/website/app/[locale]/blog/page.tsx index 9a1f478..57206e6 100644 --- a/apps/website/app/[locale]/blog/page.tsx +++ b/apps/website/app/[locale]/blog/page.tsx @@ -1,6 +1,6 @@ import { getPosts, getTags } from "@/lib/ghost"; import type { Post } from "@/lib/ghost"; -import { Search } from "lucide-react"; +import { RssIcon } from "lucide-react"; import type { Metadata } from "next"; import { getTranslations } from "next-intl/server"; import Image from "next/image"; @@ -48,13 +48,20 @@ export default async function BlogPage({ }); return ( -
-
-

{t("title")}

-
- - Welcome to the blog +
+
+
+

+ BLOG +

+

Stories behind the magic

+ + +
{filteredPosts.length === 0 ? ( -
-

+

+

{search || selectedTag ? t("noResults") : t("noPosts")} -

) : ( -
+
{filteredPosts.map((post: Post) => ( ))} @@ -91,47 +97,51 @@ function BlogPostCard({ post, locale }: { post: Post; locale: string }) { }); return ( - -
+ +
{post.feature_image && ( -
+
{post.title}
)} -
-

+
+

{post.title}

-

- {formattedDate} • {post.reading_time} min read -

-

+

{post.custom_excerpt || post.excerpt}

-
- {post.primary_author?.profile_image && ( -
- {post.primary_author.name} -
- )} -
-

- {post.primary_author?.name || "Unknown Author"} -

+
+
+ {post.primary_author?.profile_image && ( +
+ {post.primary_author.name} +
+ )} + {post.primary_author?.name || "Unknown Author"}
+ in + {post.primary_tag?.name || "General"} + + {post.reading_time} min read + + {formattedDate}
-
+

); } diff --git a/apps/website/app/rss.xml/route.ts b/apps/website/app/rss.xml/route.ts new file mode 100644 index 0000000..be9041c --- /dev/null +++ b/apps/website/app/rss.xml/route.ts @@ -0,0 +1,46 @@ +import { getPosts } from "@/lib/ghost"; +import { NextResponse } from "next/server"; + +export async function GET() { + const posts = await getPosts(); + + const rss = ` + + + Dokploy Blog + https://dokploy.com/blog + Stories behind the magic + en + ${new Date().toUTCString()} + ${posts + .map( + (post) => ` + + <![CDATA[${post.title}]]> + https://dokploy.com/blog/${post.slug} + https://dokploy.com/blog/${post.slug} + + ${new Date(post.published_at).toUTCString()} + ${ + post.feature_image + ? `` + : "" + } + ${ + post.primary_author + ? `` + : "" + } + `, + ) + .join("\n")} + +`; + + return new NextResponse(rss, { + headers: { + "Content-Type": "application/xml", + "Cache-Control": "s-maxage=3600, stale-while-revalidate", + }, + }); +}