Skip to content

Commit

Permalink
chore(readme): add @vueuse/sound/nuxt docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul committed Nov 25, 2022
1 parent 4bcd680 commit 0c54e60
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,54 @@ Or, use NPM:
npm install @vueuse/sound
```

## Nuxt

If you use Nuxt 2, you must have [@nuxt/bridge](https://nuxtjs.org) setup in your project.

Once you installed it, add `@vueuse/sound/nuxt` dependency to your project.

Add `@vueuse/sound/nuxt` to the `modules` section of your `nuxt.config`:

```js
// nuxt.config.js
defineNuxtConfig({
modules: ['@vueuse/sound/nuxt']
})
```

Configure your sounds 🥁:

```js
// nuxt.config.js
defineNuxtConfig({
sound: {
sounds: {
back: {
src: "/back.wav",
options: {
volume: 0.25
}
}
}
}
})
```

You can also automatically scan an generate typings for your sounds in `public/sounds` directory by using **scan** feature:

```js
// nuxt.config.js
defineNuxtConfig({
sound: {
sounds: {
scan: true
}
}
})
```

Then move your sounds into `public/sounds` directory, and get autocompletion on `useSound({url})`.

## Examples

### Play a sound on click
Expand Down
2 changes: 1 addition & 1 deletion src/nuxt/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ModuleOptions {
scan: string | boolean

/**
* An array of sounds to register.
* An object of sounds to register.
*
* The key will be used as an identifier for the sound to use as shortcut for `useSound(id)`.
*
Expand Down

0 comments on commit 0c54e60

Please sign in to comment.