Creating slug friendly urls based on query data

routes/+page.svelte
<script>
	import HoverLink from '$lib/components/HoverLink.svelte';

	export let data;

	function MakeUrlFriendly(input) {
		return input.replace(/[^a-zA-Z0-9]+/g, '-').toLowerCase();
	}
</script>

<a href="/werk/{MakeUrlFriendly(post.name)}">

Replace post.name with the name of your data object.

Last updated