Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to override a resolver on v3 #24

Open
alvarosabu opened this issue Jul 11, 2022 · 1 comment
Open

How to override a resolver on v3 #24

alvarosabu opened this issue Jul 11, 2022 · 1 comment

Comments

@alvarosabu
Copy link

Hi there,

I need to override a Resolver for NodeTypes.CODE_BLOCK to add a component with a specific class no-prose and Highlight it with Prism.

So following the config options I'm trying like this:

import { plugin } from '@marvr/storyblok-rich-text-vue-renderer'
import { NodeTypes } from '@marvr/storyblok-rich-text-types'

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(
    plugin({
      resolvers: {
        components: {
          [NodeTypes.CODE_BLOCK]: ({ children, attrs }) => h('pre', attrs, h('code', { class: "no-prose" } , children)),
        },
      },
    }),
  )
})

But I get an Invalid vnode type when creating vnode: undefined.

How can I add a custom component for the resolver?

Thanks

@westberliner
Copy link

Hi,

just for documentation's sake. I guess you already got this:

import { plugin } from '@marvr/storyblok-rich-text-vue-renderer'
import { NodeTypes } from '@marvr/storyblok-rich-text-types'
import { defaultResolvers } from '@marvr/storyblok-rich-text-vue-renderer';

defaultResolvers[NodeTypes.CODE_BLOCK] = ({ children, attrs }) => h('pre', attrs, h('code', { class: "no-prose" } , children)),

const resolvers = {
  ...defaultResolvers,
  components: {
     SomeCustomVueComponentIfAny
  }
};

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(
    plugin({
      resolvers
    }),
  )
})

Components are for Vue components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants