From c83808a7e8aa4581c79803f3f2ae376ec06f6ee2 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Tue, 20 May 2025 22:00:31 +0200 Subject: [PATCH] Add metadata (title etc.) to blog pages Signed-off-by: Julius Volz --- src/app/blog/[year]/[month]/[day]/[slug]/page.tsx | 15 +++++++++++++++ src/app/blog/page.tsx | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/app/blog/[year]/[month]/[day]/[slug]/page.tsx b/src/app/blog/[year]/[month]/[day]/[slug]/page.tsx index 8b7657ce..123a5161 100644 --- a/src/app/blog/[year]/[month]/[day]/[slug]/page.tsx +++ b/src/app/blog/[year]/[month]/[day]/[slug]/page.tsx @@ -7,6 +7,21 @@ export async function generateStaticParams() { return getAllPostParams(); } +export async function generateMetadata({ + params, +}: { + params: Promise<{ year: string; month: string; day: string; slug: string }>; +}) { + const { frontmatter } = getPost(await params); + return { + title: `${frontmatter.title} | Prometheus`, + openGraph: { + title: `${frontmatter.title} | Prometheus`, + url: `https://prometheus.io/blog/${frontmatter.slug}`, + }, + }; +} + export default async function BlogPostPage({ params, }: { diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx index f4b92c1e..8fefdf6b 100644 --- a/src/app/blog/page.tsx +++ b/src/app/blog/page.tsx @@ -4,6 +4,16 @@ import { Anchor, Title, Text, Card, Stack, Button, Box } from "@mantine/core"; import dayjs from "dayjs"; import Link from "next/link"; +export async function generateMetadata() { + return { + title: "Blog | Prometheus", + openGraph: { + title: "Blog | Prometheus", + url: "https://prometheus.io/blog", + }, + }; +} + export default function BlogPage() { const allPosts = getAllPosts();