silencesys / silentbox

A lightbox inspired Vue.js component.
https://silentbox.rocek.dev
MIT License
296 stars 51 forks source link

Nuxt 3 Support #66

Open MerelyPerfect opened 1 year ago

MerelyPerfect commented 1 year ago

Can it support Nuxt 3 to re-use it as a component or plugin?

Providing some example code/app would be helpful.

xelaris commented 1 year ago

I'm not sure about SSR, but in general it's as simple as adding such plugin file:

// plugins/vue-silentbox.ts
import VueSilentbox from 'vue-silentbox';
import 'vue-silentbox/dist/style.css';

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VueSilentbox);
});

to be able to use the component like this:

<template>
  <silent-box :gallery="items" />
</template>

https://nuxt.com/docs/guide/directory-structure/plugins#vue-plugins