Skip to content

Commit 36ccc89

Browse files
committed
Map over sectionKindNames
1 parent 27a4525 commit 36ccc89

File tree

1 file changed

+6
-7
lines changed
  • src/app/(main)/resources/[category]

1 file changed

+6
-7
lines changed

src/app/(main)/resources/[category]/texts.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,10 @@ export const sectionKindNames: Record<Kind, string> = {
146146
docs: "Documentation",
147147
}
148148

149-
export function sectionId(name: string): string {
150-
return name
151-
.toLowerCase()
152-
.replace(/ & /g, "-and-")
153-
.replace(/[^a-z0-9-]/g, "")
154-
.replace(/-+/g, "-")
155-
.replace(/^-|-$/g, "")
149+
export function slugify(name: string): string {
150+
return name.toLowerCase().replace(/ & /g, "-and-").replace(/ /g, "-")
156151
}
152+
153+
export const sectionIds: Record<Kind, string> = Object.fromEntries(
154+
Object.entries(sectionKindNames).map(([kind, name]) => [kind, slugify(name)]),
155+
) as Record<Kind, string>

0 commit comments

Comments
 (0)