Easy way to integrate Slugify with Nuxt 3
- Add
nuxt-slugify
dependency to your project
npm i -D nuxt-slugify
- Add
nuxt-slugify
to themodules
section 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:prepare
to generate type stubs. - Use
npm run dev
to start playground in development mode.