feat(agenda): add weekly agenda experience
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { BlogDetailContent } from "@/components/blog-detail-content";
|
||||
import { ArticleJsonLd } from "@/components/json-ld";
|
||||
import { getBlogDetailBySlug } from "@/data/blog-detail";
|
||||
import { isNewsletterCategory } from "@/data/blog";
|
||||
|
||||
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://poyrazavsever.com";
|
||||
|
||||
type AgendaDetailPageProps = {
|
||||
params: Promise<{ locale: string; slug: string }>;
|
||||
};
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: AgendaDetailPageProps): Promise<Metadata> {
|
||||
const { locale, slug } = await params;
|
||||
const post = await getBlogDetailBySlug(slug);
|
||||
|
||||
if (!post || post.lang !== locale || !isNewsletterCategory(post.category)) {
|
||||
return { title: locale === "en" ? "Agenda post not found" : "Gündem yazısı bulunamadı" };
|
||||
}
|
||||
|
||||
const url = `${SITE_URL}${locale === "en" ? "/en" : ""}/agenda/${post.slug}`;
|
||||
|
||||
return {
|
||||
title: post.title,
|
||||
description: post.excerpt,
|
||||
alternates: { canonical: url },
|
||||
openGraph: {
|
||||
title: post.title,
|
||||
description: post.excerpt,
|
||||
url,
|
||||
type: "article",
|
||||
publishedTime: post.date,
|
||||
authors: [post.author],
|
||||
images: [
|
||||
{
|
||||
url: post.coverImage,
|
||||
width: 1200,
|
||||
height: 630,
|
||||
alt: post.title,
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: post.title,
|
||||
description: post.excerpt,
|
||||
images: [post.coverImage],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function AgendaDetailPage({ params }: AgendaDetailPageProps) {
|
||||
const { locale, slug } = await params;
|
||||
const post = await getBlogDetailBySlug(slug);
|
||||
|
||||
if (!post || post.lang !== locale || !isNewsletterCategory(post.category)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const url = `${SITE_URL}${locale === "en" ? "/en" : ""}/agenda/${post.slug}`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<ArticleJsonLd
|
||||
title={post.title}
|
||||
description={post.excerpt}
|
||||
url={url}
|
||||
image={post.coverImage}
|
||||
datePublished={post.date}
|
||||
authorName={post.author}
|
||||
/>
|
||||
<BlogDetailContent post={post} section="agenda" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { BlogContent } from "@/components/blog-content";
|
||||
import { getAgendaPageData } from "@/data/blog";
|
||||
|
||||
type AgendaPageProps = {
|
||||
params: Promise<{ locale: string }>;
|
||||
searchParams?: Promise<{
|
||||
page?: string | string[];
|
||||
search?: string | string[];
|
||||
}>;
|
||||
};
|
||||
|
||||
export async function generateMetadata({ params }: AgendaPageProps): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({ locale, namespace: "Agenda" });
|
||||
|
||||
return {
|
||||
title: t("title"),
|
||||
description: t("description"),
|
||||
};
|
||||
}
|
||||
|
||||
export default async function AgendaPage({ params, searchParams }: AgendaPageProps) {
|
||||
const { locale } = await params;
|
||||
const resolved = searchParams ? await searchParams : undefined;
|
||||
const pageParam = Array.isArray(resolved?.page) ? resolved.page[0] : resolved?.page;
|
||||
const searchParam = Array.isArray(resolved?.search)
|
||||
? resolved.search[0]
|
||||
: resolved?.search;
|
||||
const page = Number(pageParam ?? "1");
|
||||
const currentPage = Number.isFinite(page) && page > 0 ? Math.floor(page) : 1;
|
||||
const data = await getAgendaPageData(locale, currentPage, 12, searchParam);
|
||||
|
||||
return <BlogContent data={data} section="agenda" />;
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { notFound, permanentRedirect } from "next/navigation";
|
||||
import { Metadata } from "next";
|
||||
import { BlogDetailContent } from "@/components/blog-detail-content";
|
||||
import { ArticleJsonLd } from "@/components/json-ld";
|
||||
import { getBlogDetailBySlug } from "@/data/blog-detail";
|
||||
import { isNewsletterCategory } from "@/data/blog";
|
||||
|
||||
const SITE_URL = process.env.NEXT_PUBLIC_SITE_URL || "https://poyrazavsever.com";
|
||||
|
||||
@@ -58,6 +59,11 @@ export default async function BlogDetailPage({ params }: BlogDetailPageProps) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
if (isNewsletterCategory(post.category)) {
|
||||
const localePrefix = locale === "tr" ? "" : `/${locale}`;
|
||||
permanentRedirect(`${localePrefix}/agenda/${post.slug}`);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<ArticleJsonLd
|
||||
|
||||
Reference in New Issue
Block a user