feat(announcements): add locale audience targeting and published-home news

This commit is contained in:
2026-02-12 23:05:39 +01:00
parent 741883465c
commit 60c9035743
10 changed files with 93 additions and 12 deletions

View File

@@ -52,7 +52,7 @@ export default async function LocaleLayout({ children, params }: LocaleLayoutPro
<NextIntlClientProvider locale={locale}>
<Providers>
<PublicHeaderBanner banner={banner} />
<PublicAnnouncements placement="global_top" />
<PublicAnnouncements placement="global_top" locale={locale} />
<PublicSiteHeader />
<main>{children}</main>
<PublicSiteFooter />

View File

@@ -1,4 +1,4 @@
import { getPublishedPageBySlugForLocale, listPosts } from "@cms/db"
import { getPublishedPageBySlugForLocale, listPostsForLocale } from "@cms/db"
import { getTranslations } from "next-intl/server"
import { PublicAnnouncements } from "@/components/public-announcements"
import { PublicPageView } from "@/components/public-page-view"
@@ -15,14 +15,14 @@ export default async function HomePage({ params }: HomePageProps) {
const [homePage, posts, t] = await Promise.all([
getPublishedPageBySlugForLocale("home", locale),
listPosts(),
listPostsForLocale(locale),
getTranslations("Home"),
])
return (
<section>
{homePage ? <PublicPageView page={homePage} /> : null}
<PublicAnnouncements placement="homepage" />
<PublicAnnouncements placement="homepage" locale={locale} />
<section className="mx-auto flex w-full max-w-6xl flex-col gap-6 px-6 py-6 pb-16">
<header className="space-y-3">

View File

@@ -3,6 +3,7 @@ import Link from "next/link"
type PublicAnnouncementsProps = {
placement: "global_top" | "homepage"
locale?: string
}
function AnnouncementCard({ announcement }: { announcement: PublicAnnouncement }) {
@@ -22,8 +23,8 @@ function AnnouncementCard({ announcement }: { announcement: PublicAnnouncement }
)
}
export async function PublicAnnouncements({ placement }: PublicAnnouncementsProps) {
const announcements = await listActiveAnnouncements(placement)
export async function PublicAnnouncements({ placement, locale }: PublicAnnouncementsProps) {
const announcements = await listActiveAnnouncements(placement, new Date(), locale)
if (announcements.length === 0) {
return null