Skip to content

Commit 6303f74

Browse files
authored
Merge pull request #939 from hirosystems/develop
chore/updates
2 parents 99b28e1 + 536c127 commit 6303f74

File tree

3 files changed

+77
-37
lines changed

3 files changed

+77
-37
lines changed

app/(docs)/[...slug]/page.tsx

+6-36
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RollButton } from "fumadocs-ui/components/roll-button";
44
import { DocsPage, DocsBody } from "fumadocs-ui/page";
55
import { notFound } from "next/navigation";
66
import { utils, type Page } from "@/utils/source";
7-
import { createMetadata } from "@/utils/metadata";
7+
import { createMetadata, getRouteMetadata } from "@/utils/metadata";
88

99
interface Param {
1010
slug: string[];
@@ -71,45 +71,15 @@ function Category({ page }: { page: Page }): JSX.Element {
7171
);
7272
}
7373

74-
const metadata: Metadata = {
75-
metadataBase: new URL(
76-
`https://${process.env.NEXT_PUBLIC_VERCEL_URL}` || "https://docs.hiro.so"
77-
),
78-
title: "Hiro Docs",
79-
description:
80-
"All the developer docs, guides and resources you need to build on Bitcoin layers.",
81-
openGraph: {
82-
title: "Hiro Docs",
83-
description:
84-
"All the developer docs, guides and resources you need to build on Bitcoin layers.",
85-
url: "https://docs.hiro.so",
86-
siteName: "Hiro Docs",
87-
images: [
88-
{
89-
url: "/og.jpg",
90-
width: 800,
91-
height: 600,
92-
},
93-
],
94-
locale: "en_US",
95-
type: "website",
96-
},
97-
twitter: {
98-
card: "summary_large_image",
99-
title: "Hiro Docs",
100-
description:
101-
"All the developer docs, guides and resources you need to build on Bitcoin layers.",
102-
creator: "@hirosystems",
103-
images: ["/og.jpg"], // Must be an absolute URL
104-
},
105-
};
106-
10774
export async function generateMetadata(props: {
10875
params: Promise<{ slug?: string[] }>;
109-
}) {
76+
}): Promise<Metadata> {
11077
const params = await props.params;
11178
const page = utils.getPage(params.slug);
11279
if (!page) notFound();
11380

114-
return metadata;
81+
const path = `/${params.slug?.join("/") || ""}`;
82+
const routeMetadata = getRouteMetadata(path);
83+
84+
return createMetadata(routeMetadata);
11585
}
419 KB
Loading

utils/metadata.ts

+71-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,82 @@
11
import type { Metadata } from "next/types";
22

3-
export function createMetadata(override: Metadata): Metadata {
3+
const defaultMetadata: Metadata = {
4+
title: "Hiro Docs",
5+
description:
6+
"All the developer docs, guides and resources you need to build on Bitcoin layers.",
7+
openGraph: {
8+
title: "Hiro Docs",
9+
description:
10+
"All the developer docs, guides and resources you need to build on Bitcoin layers.",
11+
url: "https://docs.hiro.so",
12+
siteName: "Hiro Docs",
13+
images: [
14+
{
15+
url: "/og.jpg",
16+
width: 800,
17+
height: 600,
18+
},
19+
],
20+
locale: "en_US",
21+
type: "website",
22+
},
23+
twitter: {
24+
card: "summary_large_image",
25+
title: "Hiro Docs",
26+
description:
27+
"All the developer docs, guides and resources you need to build on Bitcoin layers.",
28+
creator: "@hirosystems",
29+
images: ["/og.jpg"],
30+
},
31+
};
32+
33+
const hiroHacksMetadata: Partial<Metadata> = {
34+
title: "Hiro Hacks - Season 1",
35+
description:
36+
"Join Hiro Hacks Season 1 and build on Bitcoin layers with our monthly themed challenges.",
37+
openGraph: {
38+
title: "Hiro Hacks - Season 1",
39+
description:
40+
"Join Hiro Hacks Season 1 and build on Bitcoin layers with our monthly themed challenges.",
41+
images: [
42+
{
43+
url: "/images/hiro-hacks-season-one.png",
44+
width: 800,
45+
height: 600,
46+
},
47+
],
48+
},
49+
twitter: {
50+
title: "Hiro Hacks - Season 1",
51+
description:
52+
"Join Hiro Hacks Season 1 and build on Bitcoin layers with our monthly themed challenges.",
53+
images: ["/images/hiro-hacks-season-one.png"],
54+
},
55+
};
56+
57+
export function createMetadata(override: Partial<Metadata>): Metadata {
458
return {
59+
...defaultMetadata,
560
...override,
61+
openGraph: {
62+
...defaultMetadata.openGraph,
63+
...override.openGraph,
64+
},
65+
twitter: {
66+
...defaultMetadata.twitter,
67+
...override.twitter,
68+
},
669
};
770
}
871

972
export const baseUrl =
1073
process.env.NODE_ENV === "development"
1174
? new URL("http://localhost:3000")
1275
: new URL(`https://${process.env.NEXT_PUBLIC_VERCEL_URL!}`);
76+
77+
export function getRouteMetadata(path: string): Partial<Metadata> {
78+
if (path.startsWith("/stacks/hacks")) {
79+
return hiroHacksMetadata;
80+
}
81+
return {};
82+
}

0 commit comments

Comments
 (0)