Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions frontend/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,33 @@ import { CookieBanner } from '@/components/shared/CookieBanner';
import Footer from '@/components/shared/Footer';
import { ScrollWatcher } from '@/components/shared/ScrollWatcher';
import { ThemeProvider } from '@/components/theme/ThemeProvider';
import { getCachedBlogCategories } from '@/db/queries/blog/blog-categories';
import { AuthProvider } from '@/hooks/useAuth';
import { locales } from '@/i18n/config';
import { readServerEnv } from '@/lib/env/server-env';

type BlogCategory = {
id: string;
slug: string;
title: string;
};

async function getLayoutBlogCategories(locale: string): Promise<BlogCategory[]> {
try {
const { getCachedBlogCategories } = await import(
'@/db/queries/blog/blog-categories'
);

return await getCachedBlogCategories(locale);
} catch (error) {
console.error(
`[layout] failed to load blog categories for locale "${locale}"`,
error
);

return [];
}
}

export default async function LocaleLayout({
children,
params,
Expand All @@ -28,7 +50,7 @@ export default async function LocaleLayout({

const [messages, blogCategories] = await Promise.all([
getMessages({ locale }),
getCachedBlogCategories(locale),
getLayoutBlogCategories(locale),
]);

const enableAdmin =
Expand Down
4 changes: 3 additions & 1 deletion frontend/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export async function generateMetadata({
}) {
const { locale } = await params;
const t = await getTranslations({ locale, namespace: 'homepage' });
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL ?? 'https://devlovers.net';
const siteUrl = (
process.env.NEXT_PUBLIC_SITE_URL ?? 'https://devlovers.net'
).replace(/\/$/, '');
const canonicalUrl =
locale === 'en' ? `${siteUrl}/en` : `${siteUrl}/${locale}`;
const localeMap: Record<string, string> = {
Expand Down