Easy way to integrate Slugify with Nuxt 3
- Add
nuxt-slugifydependency to your project
npm i -D nuxt-slugify- Add
nuxt-slugifyto themodulessection ofnuxt.config.ts.
You can use the slugify method with the injected function or with the composable:
<template>
<div>
{{ $slugify('Hello world @ Slugify! 🐱') }}
</div>
</template>
<script setup lang="ts">
const slugify = useSlugify()
onMounted(() => {
console.log(slugify('Hello world @ Slugify! 🐱'))
})
</script>export default defineNuxtConfig({
modules: ['nuxt-slugify'],
slugify: {
defaults: {
// global settings
},
extend: {
// extend support
},
}
})More information in the Slugify repository
- Run
npm run dev:prepareto generate type stubs. - Use
npm run devto start playground in development mode.