Skip to content

Commit d227f6a

Browse files
authored
Merge pull request #982 from hirosystems/fix/analytics
fix/analytics
2 parents acbd005 + 6fddb73 commit d227f6a

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

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

+51-1
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,55 @@ export async function generateMetadata(props: {
8181
const path = `/${params.slug?.join("/") || ""}`;
8282
const routeMetadata = getRouteMetadata(path);
8383

84-
return createMetadata(routeMetadata);
84+
const pathParts = path.split("/").filter(Boolean);
85+
86+
const genericTitles = [
87+
"Overview",
88+
"Installation",
89+
"Quickstart",
90+
"Concepts",
91+
"Getting Started",
92+
];
93+
94+
let title = page.data.title;
95+
96+
if (page.file.name === "index" || genericTitles.includes(title)) {
97+
let sectionName =
98+
page.file.name === "index"
99+
? pathParts[pathParts.length - 1]
100+
: pathParts[pathParts.length - 2] || pathParts[pathParts.length - 1];
101+
102+
if (sectionName === "api" && pathParts.length >= 2) {
103+
const parentSection = pathParts[pathParts.length - 2];
104+
if (parentSection === "runes" || parentSection === "ordinals") {
105+
const capitalizedParent =
106+
parentSection.charAt(0).toUpperCase() + parentSection.slice(1);
107+
sectionName = `${capitalizedParent} API`;
108+
}
109+
}
110+
111+
const sectionTitle = sectionName
112+
.split("-")
113+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
114+
.join(" ")
115+
.replace("Api", "API")
116+
.replace("Js", "JS")
117+
.replace("Sdk", "SDK");
118+
119+
if (page.file.name === "index") {
120+
title = `${sectionTitle} Overview`;
121+
} else {
122+
title = `${sectionTitle} ${title}`;
123+
}
124+
}
125+
126+
const pageMetadata: Partial<Metadata> = {
127+
title,
128+
description: page.data.description,
129+
};
130+
131+
return createMetadata({
132+
...routeMetadata,
133+
...pageMetadata,
134+
});
85135
}

0 commit comments

Comments
 (0)