mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-07-03 12:06:39 -04:00
extract metadata merging logic from each page into a helper function
This commit is contained in:
@ -1,23 +1,16 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import Video from "../../components/Video";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { Metadata } from "next";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
import thumbnail from "./thumbnail.png";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "🎉 Cranky Birthday Boy on VHS Tape 📼",
|
||||
description: "The origin of my hatred for the Happy Birthday song.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "🎉 Cranky Birthday Boy on VHS Tape 📼",
|
||||
url: "/birthday",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/birthday",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
|
@ -1,19 +1,13 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
export const metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "CLI",
|
||||
description: "AKA, the most useless Node module ever published, in history, by anyone, ever.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "CLI",
|
||||
url: "/cli",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/cli",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
<PageTitle canonical="/cli">CLI</PageTitle>
|
||||
|
||||
|
@ -1,22 +1,16 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import Link from "../../components/Link";
|
||||
import ContactForm from "./form";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { Metadata, Route } from "next";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
import type { Route } from "next";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "Contact Me",
|
||||
description: "Fill out this quick form and I'll get back to you as soon as I can.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "Contact Me",
|
||||
url: "/contact",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/contact",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
|
@ -1,24 +1,17 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import Link from "../../components/Link";
|
||||
import Video from "../../components/Video";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { Metadata } from "next";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
import thumbnail from "./thumbnail.png";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "My Brief Apperance in Hillary Clinton's DNC Video",
|
||||
description: "My brief apperance in one of Hillary Clinton's 2016 DNC convention videos on substance abuse.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "My Brief Apperance in Hillary Clinton's DNC Video",
|
||||
url: "/hillary",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/hillary",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
|
@ -6,6 +6,7 @@ import Footer from "../components/Footer";
|
||||
import { SkipToContentLink, SkipToContentTarget } from "../components/SkipToContent";
|
||||
import * as config from "../lib/config";
|
||||
import { BASE_URL, MAX_WIDTH } from "../lib/config/constants";
|
||||
import defaultMetadata from "../lib/config/metadata";
|
||||
import type { Metadata } from "next";
|
||||
import type { Person, WithContext } from "schema-dts";
|
||||
|
||||
@ -18,47 +19,7 @@ import styles from "./layout.module.css";
|
||||
|
||||
import ogImage from "./opengraph-image.jpg";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
metadataBase: new URL(BASE_URL),
|
||||
title: {
|
||||
template: `%s – ${config.siteName}`,
|
||||
default: `${config.siteName} – ${config.shortDescription}`,
|
||||
},
|
||||
description: config.longDescription,
|
||||
openGraph: {
|
||||
siteName: config.siteName,
|
||||
title: {
|
||||
template: "%s",
|
||||
default: `${config.siteName} – ${config.shortDescription}`,
|
||||
},
|
||||
url: "/",
|
||||
locale: config.siteLocale?.replace("-", "_"),
|
||||
type: "website",
|
||||
},
|
||||
twitter: {
|
||||
creator: `@${config.authorSocial?.twitter}`,
|
||||
},
|
||||
alternates: {
|
||||
canonical: "/",
|
||||
types: {
|
||||
"application/rss+xml": [
|
||||
{
|
||||
title: `${config.siteName} (RSS)`,
|
||||
url: "/feed.xml",
|
||||
},
|
||||
],
|
||||
"application/atom+xml": [
|
||||
{
|
||||
title: `${config.siteName} (Atom)`,
|
||||
url: "/feed.atom",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
other: {
|
||||
humans: "/humans.txt",
|
||||
},
|
||||
};
|
||||
export const metadata: Metadata = defaultMetadata;
|
||||
|
||||
// https://nextjs.org/docs/app/building-your-application/optimizing/metadata#json-ld
|
||||
const jsonLd: WithContext<Person> = {
|
||||
|
@ -1,24 +1,17 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import Link from "../../components/Link";
|
||||
import Video from "../../components/Video";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { Metadata } from "next";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
import thumbnail from "./thumbnail.png";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: 'Facebook App on "The Lab with Leo Laporte"',
|
||||
description: "Powncer app featured in Leo Laporte's TechTV show.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: 'Facebook App on "The Lab with Leo Laporte"',
|
||||
url: "/leo",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/leo",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
|
@ -1,18 +1,12 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
export const metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "License",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "License",
|
||||
url: "/license",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/license",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
<PageTitle canonical="/license">License</PageTitle>
|
||||
|
||||
|
@ -7,7 +7,7 @@ import Comments from "../../../components/Comments";
|
||||
import Loading from "../../../components/Loading";
|
||||
import HitCounter from "./counter";
|
||||
import { getPostSlugs, getFrontMatter } from "../../../lib/helpers/posts";
|
||||
import { metadata as defaultMetadata } from "../../layout";
|
||||
import { addMetadata } from "../../../lib/helpers/metadata";
|
||||
import * as config from "../../../lib/config";
|
||||
import { BASE_URL } from "../../../lib/config/constants";
|
||||
import type { Metadata, Route } from "next";
|
||||
@ -34,13 +34,10 @@ export const generateMetadata = async ({ params }: { params: Promise<{ slug: str
|
||||
const { slug } = await params;
|
||||
const frontmatter = await getFrontMatter(slug);
|
||||
|
||||
return {
|
||||
return addMetadata({
|
||||
title: frontmatter.title,
|
||||
description: frontmatter.description,
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: frontmatter.title,
|
||||
url: `/notes/${slug}`,
|
||||
type: "article",
|
||||
authors: [config.authorName],
|
||||
tags: frontmatter.tags,
|
||||
@ -48,14 +45,12 @@ export const generateMetadata = async ({ params }: { params: Promise<{ slug: str
|
||||
modifiedTime: frontmatter.date,
|
||||
},
|
||||
twitter: {
|
||||
...defaultMetadata.twitter,
|
||||
card: "summary_large_image",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: `/notes/${slug}`,
|
||||
},
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const Page = async ({ params }: { params: Promise<{ slug: string }> }) => {
|
||||
|
@ -1,27 +1,21 @@
|
||||
import Link from "../../components/Link";
|
||||
import Time from "../../components/Time";
|
||||
import { getAllPosts } from "../../lib/helpers/posts";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
import * as config from "../../lib/config";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { ReactElement } from "react";
|
||||
import type { Metadata, Route } from "next";
|
||||
import type { Route } from "next";
|
||||
import type { FrontMatter } from "../../lib/helpers/posts";
|
||||
|
||||
import styles from "./page.module.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "Notes",
|
||||
description: `Recent posts by ${config.authorName}.`,
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "Notes",
|
||||
url: "/notes",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/notes",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = async () => {
|
||||
// parse the year of each note and group them together
|
||||
|
@ -3,8 +3,7 @@ import Link from "../../components/Link";
|
||||
import Figure from "../../components/Figure";
|
||||
import CodeInline from "../../components/CodeInline";
|
||||
import HorizontalRule from "../../components/HorizontalRule";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { Metadata } from "next";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
import { ComicNeue } from "../../lib/styles/fonts";
|
||||
import styles from "./page.module.css";
|
||||
@ -24,19 +23,13 @@ import img_2012_09 from "./images/2012_09.png";
|
||||
import img_2018_04 from "./images/2018_04.png";
|
||||
import img_2020_03 from "./images/2020_03.png";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "Previously on...",
|
||||
description: "An incredibly embarrassing and somewhat painful trip down this site's memory lane...",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "Previously on...",
|
||||
url: "/previously",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/previously",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
|
@ -1,18 +1,12 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
export const metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "Privacy",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "Privacy",
|
||||
url: "/privacy",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/privacy",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
<PageTitle canonical="/privacy">Privacy</PageTitle>
|
||||
|
||||
|
@ -4,27 +4,21 @@ import { GitForkIcon, StarIcon } from "lucide-react";
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import Link from "../../components/Link";
|
||||
import RelativeTime from "../../components/RelativeTime";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
import * as config from "../../lib/config";
|
||||
import type { Metadata } from "next";
|
||||
import type { User, Repository } from "@octokit/graphql-schema";
|
||||
|
||||
import styles from "./page.module.css";
|
||||
|
||||
export const revalidate = 600; // 10 minutes
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "Projects",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "Projects",
|
||||
url: "/projects",
|
||||
},
|
||||
description: `Most-starred repositories by @${config.authorSocial?.github} on GitHub`,
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/projects",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
type Project = {
|
||||
name: string;
|
||||
|
@ -1,19 +1,13 @@
|
||||
import PageTitle from "../../components/PageTitle";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
export const metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "/uses",
|
||||
description: "Things I use daily.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "/uses",
|
||||
url: "/uses",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/uses",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
<PageTitle canonical="/uses">Uses</PageTitle>
|
||||
|
||||
|
@ -1,23 +1,16 @@
|
||||
import Link from "../../components/Link";
|
||||
import CodeBlock from "../../components/CodeBlock/CodeBlock";
|
||||
import { metadata as defaultMetadata } from "../layout";
|
||||
import type { Metadata } from "next";
|
||||
import { addMetadata } from "../../lib/helpers/metadata";
|
||||
|
||||
import backgroundImg from "./sundar.jpg";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
export const metadata = addMetadata({
|
||||
title: "fuckyougoogle.zip",
|
||||
description: "This is a horrible idea.",
|
||||
openGraph: {
|
||||
...defaultMetadata.openGraph,
|
||||
title: "fuckyougoogle.zip",
|
||||
url: "/zip",
|
||||
},
|
||||
alternates: {
|
||||
...defaultMetadata.alternates,
|
||||
canonical: "/zip",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const Page = () => {
|
||||
return (
|
||||
|
Reference in New Issue
Block a user