Skip to content

Commit

Permalink
adding static metadata and dynamically upating title per blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
nspilman committed Jan 13, 2024
1 parent 907c619 commit 96e4160
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/app/blog/[slug]/page.tsx
@@ -1,9 +1,22 @@
import { getAllPosts, getPostBySlug } from "@/lib/api";
import { markdownToHtml } from "@/lib/utils";
import { formatDateString } from "@/utils";
import { Metadata } from "next";
import Link from "next/link";
import React from "react";

interface Props {
params: {
slug: string;
};
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
return {
title: getPostBySlug(params.slug).frontmatter.title,
};
}

export default async function Post({ params }: { params: { slug: string } }) {
const post = getPostBySlug(params.slug);
const allPosts = getAllPosts();
Expand Down
5 changes: 5 additions & 0 deletions src/app/blog/page.tsx
@@ -1,6 +1,11 @@
import React from "react";
import { getAllPosts } from "@/lib/api";
import Post from "@/components/Post";
import { Metadata } from "next";

export const metadata: Metadata = {
title: "Blog",
};

const BlogPage = () => {
const posts = getAllPosts();
Expand Down
8 changes: 7 additions & 1 deletion src/app/layout.tsx
Expand Up @@ -3,9 +3,15 @@ import "../../public/css/globals.css";
import { Layout } from "@/components/layout";

export const metadata: Metadata = {
title: "Nate Spilman Dot Com",
title: {
absolute: "Nate Spilman Dot Com",
template: "%s | Nate Spilman Dot Com",
},
description: "Nate Spilman's Personal Website",
icons: "/favicon.png",
authors: [{ name: "Nate Spilman", url: "https://natespilman.com" }],
creator: "Nate Spilman",
publisher: "Nate Spilman",
};

export default function RootLayout({
Expand Down

0 comments on commit 96e4160

Please sign in to comment.