Skip to content

Commit

Permalink
Slugify language names for preview title IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
spenserblack committed Aug 25, 2023
1 parent 07dd12f commit c6913f3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/vercel/src/lib/TitleLink.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<script lang="ts">
export let name: string;
$: slug = name
.toLowerCase()
.replace(/ /g, '-')
.replace(/#/g, '-sharp')
.replace(/\+/g, '-plus')
.replace(/[^a-z0-9-]/g, '');
</script>

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

<style>
.title-link,
Expand Down

0 comments on commit c6913f3

Please sign in to comment.