diff --git a/app/[lang]/layout.tsx b/app/[lang]/layout.tsx index 2054a73..5757364 100644 --- a/app/[lang]/layout.tsx +++ b/app/[lang]/layout.tsx @@ -5,6 +5,7 @@ import Image from "next/image"; import avatar from "../../public/static/avatar.webp"; import Link from "next/link"; import { dictionaryKeys, getDictionary } from "../../dictionaries"; +import { getAlternateLanguages } from "@/lib/metadata"; export const runtime = "edge"; @@ -15,20 +16,14 @@ export async function generateMetadata({ }): Promise { const dictionary = await getDictionary(params.lang); - const langEntries = await Promise.all( - dictionaryKeys.map(async (lang) => { - const dictionary = await getDictionary(lang); - - return [lang, dictionary.urls.home]; - }), - ); - return { metadataBase: new URL(dictionary.meta.baseUrl), title: dictionary.meta.websiteName, description: dictionary.meta.motto, keywords: dictionary.meta.fillKeywords([]), openGraph: { + type: "website", + url: new URL(dictionary.urls.home, dictionary.meta.baseUrl).href, title: dictionary.meta.websiteName, description: dictionary.meta.motto, siteName: dictionary.meta.websiteName, @@ -42,7 +37,10 @@ export async function generateMetadata({ images: "/static/banner.png", }, alternates: { - languages: Object.fromEntries(langEntries), + languages: await getAlternateLanguages( + (dictionary) => + new URL(dictionary.urls.home, dictionary.meta.baseUrl).href, + ), }, }; } diff --git a/app/[lang]/posts/[postSlug]/page.tsx b/app/[lang]/posts/[postSlug]/page.tsx index 6cb6cf5..068320e 100644 --- a/app/[lang]/posts/[postSlug]/page.tsx +++ b/app/[lang]/posts/[postSlug]/page.tsx @@ -3,11 +3,17 @@ import { CalendarDaysIcon, LanguageIcon } from "@heroicons/react/24/solid"; import { displayDate } from "@/lib/date"; import { notFound } from "next/navigation"; import Link from "next/link"; -import { getDictionary, Language, languageLabels } from "@/dictionaries"; +import { + dictionaryKeys, + getDictionary, + Language, + languageLabels, +} from "@/dictionaries"; import { SiX } from "@icons-pack/react-simple-icons"; import { Metadata } from "next"; import classNames from "classnames"; import { PostAdvertising } from "./Advertising"; +import { getAlternateLanguages } from "@/lib/metadata"; export const runtime = "edge"; @@ -23,8 +29,6 @@ export async function generateMetadata({ (post) => post.lang === lang && post.slug === postSlug, ); - console.log("###", post); - if (!post) { notFound(); } @@ -36,6 +40,8 @@ export async function generateMetadata({ keywords: dictionary.meta.fillKeywords(post.keywords), openGraph: { type: "article", + url: new URL(post.permalink, dictionary.meta.baseUrl).href, + siteName: dictionary.meta.websiteName, title: post.title, description: post.description, images: post.cover?.src ?? "/static/banner.png", @@ -47,6 +53,11 @@ export async function generateMetadata({ card: "summary_large_image", images: post.cover?.src ?? "/static/banner.png", }, + alternates: { + languages: await getAlternateLanguages( + (dictionary) => new URL(post.permalink, dictionary.meta.baseUrl).href, + ), + }, }; } @@ -109,8 +120,9 @@ export default async function PostPage({ className={classNames( "prose dark:prose-invert", "prose-headings:font-serif prose-headings:mt-8", - "prose-h1:text-xl", - "prose-h2:text-lg", + "prose-h1:text-3xl", + "prose-h2:text-xl", + "prose-h3:text-lg", "prose-blockquote:font-normal", "prose-pre:border prose-pre:rounded-xl", "before:prose-p:content-none after:prose-p:content-none", diff --git a/app/[lang]/posts/categories/[categorySlug]/page.tsx b/app/[lang]/posts/categories/[categorySlug]/page.tsx index 473134e..1a04eac 100644 --- a/app/[lang]/posts/categories/[categorySlug]/page.tsx +++ b/app/[lang]/posts/categories/[categorySlug]/page.tsx @@ -1,10 +1,11 @@ import { posts, categories } from "@/.velite"; import { CalendarDaysIcon } from "@heroicons/react/24/solid"; import Link from "next/link"; -import { Language, getDictionary } from "@/dictionaries"; +import { Language, dictionaryKeys, getDictionary } from "@/dictionaries"; import { Metadata } from "next"; import { notFound } from "next/navigation"; import { displayDate } from "@/lib/date"; +import { getAlternateLanguages } from "@/lib/metadata"; export const runtime = "edge"; @@ -28,8 +29,13 @@ export async function generateMetadata({ description: category.description?.[params.lang], keywords: dictionary.meta.fillKeywords([]), openGraph: { + type: "website", + url: new URL(category.permalink[params.lang], dictionary.meta.baseUrl) + .href, + siteName: dictionary.meta.websiteName, title: category.name[params.lang], description: category.description?.[params.lang], + images: "/static/banner.png", }, twitter: { title: category.name[params.lang], @@ -37,6 +43,13 @@ export async function generateMetadata({ site: "@noobnooc", card: "summary_large_image", }, + alternates: { + languages: await getAlternateLanguages( + (dictionary) => + new URL(category.permalink[params.lang], dictionary.meta.baseUrl) + .href, + ), + }, }; } @@ -69,14 +82,14 @@ export default async function CategoryPostsPage({ return (
-