highlightjs / vue-plugin

Highlight.js Vue Plugin
BSD 3-Clause "New" or "Revised" License
200 stars 28 forks source link

Export component individually #11

Closed Trinovantes closed 3 years ago

Trinovantes commented 3 years ago

I'll write some tests later when I have more time

joshgoebel commented 3 years ago

Out of curiosity how would we inject into a component? Just have a function that takes Highlight.js instance as an argument and returns a component using that instance?

Trinovantes commented 3 years ago

Out of curiosity how would we inject into a component? Just have a function that takes Highlight.js instance as an argument and returns a component using that instance?

You can pass options when you use the plugin:

app.use(hljsVuePlugin, {
  hljs
})

Then access it in the plugin install function

    install(app, { hljs }) {
        app.component('highlightjs', component) // instead of component object itself, insert a factory function that uses the hljs instance
    },