Skip to content

Commit 4ddbe3e

Browse files
Alex KrawiecAlex Krawiec
authored andcommitted
Small refactor of tag format helper function for readability
1 parent 2ca6cc4 commit 4ddbe3e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/[[...path]]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ type MetadataProps = {
133133
};
134134

135135
// Helper function to clean up canonical tags missing leading or trailing slash
136-
function checkCanonicalTagFormat(tag: string) {
136+
function formatCanonicalTag(tag: string) {
137137
if (tag.charAt(0) !== '/') {
138138
tag = '/' + tag;
139139
}
@@ -174,13 +174,13 @@ export async function generateMetadata({params}: MetadataProps): Promise<Metadat
174174
description = pageNode.frontmatter.description ?? '';
175175

176176
if (pageNode.frontmatter.customCanonicalTag) {
177-
customCanonicalTag = pageNode.frontmatter.customCanonicalTag;
177+
customCanonicalTag = formatCanonicalTag(pageNode.frontmatter.customCanonicalTag);
178178
}
179179
}
180180
}
181181

182182
const canonical = customCanonicalTag
183-
? domain + checkCanonicalTagFormat(customCanonicalTag)
183+
? domain + customCanonicalTag
184184
: params.path
185185
? `${domain}/${params.path.join('/')}/`
186186
: domain;

0 commit comments

Comments
 (0)