Skip to content

Commit c6913f3

Browse files
committed
Slugify language names for preview title IDs
1 parent 07dd12f commit c6913f3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/vercel/src/lib/TitleLink.svelte

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<script lang="ts">
22
export let name: string;
3+
4+
$: slug = name
5+
.toLowerCase()
6+
.replace(/ /g, '-')
7+
.replace(/#/g, '-sharp')
8+
.replace(/\+/g, '-plus')
9+
.replace(/[^a-z0-9-]/g, '');
310
</script>
411

5-
<h3 id={name}><a href="#{name}" class="title-link">{name}</a></h3>
12+
<h3 id={slug}><a href="#{slug}" class="title-link">{name}</a></h3>
613

714
<style>
815
.title-link,

0 commit comments

Comments
 (0)