prismicio / prismic-vue

Vue plugin, components, and composables to fetch and present Prismic content
https://prismic.io/docs/technologies/vuejs
Apache License 2.0
65 stars 16 forks source link

Components Only #18

Closed TomKremer closed 4 years ago

TomKremer commented 4 years ago

Hi,

When I try to use only the components like RichText, I get a warning with linkResolver. If I add prismic-vue dependency and init with linkResolver, the issue is gone. So my question is, what did I do wrong or is the readme (https://github.com/prismicio/prismic-vue/blame/master/README.md#L135) missing something?

Screenshot 2019-10-28 at 19 48 51

I'm backing in prismic content as i18n json files and I don't need the prismic javascript and whole prismic-vue.

Thanks for helping out. Best

hypervillain commented 4 years ago

Hey @TomKremer, I see what's going on here. The components have always been tested with third-party libraries that added a prismic property to Vue prototype. This behaviour should of course be optional.

Before we find a solution, a quick fix would be to add something like this to your app:

Vue.prototype.prismic = {
   linkResolver: () { /* ... */},
   htmlSerializer: () { /* ... */},
}

I can't test things right now, let me know if this works for you in the meantime!

TomKremer commented 4 years ago

Many thanks for your quick reply!

I got it working with the following: Vue.prototype.$prismic = { linkResolver: function(doc) { if (doc.type === 'home') { return '/'; } } }

thx

hypervillain commented 4 years ago

Happy to help! I'll get back to you to see if we make this the default behaviour or update the library. And i would love to get your opinion on that of course

hypervillain commented 4 years ago

Hey @TomKremer,

I added these lines to the README as a default behaviour. Thank you again for reporting this.