DEV Community

Discussion on: Vue Application as a Wordpress Plugin

Collapse
 
coledcrawford profile image
Cole Crawford

Got this up and running pretty smoothly, thanks for the walkthrough.

I have a situation where a site is mostly Wordpress, but I'm using Vue + Wordpress REST API for a few features that are more dynamic. These Vue features are on ~6 different pages. They use some shared components, but have different base templates. Eg PostsPage.vue and PeoplePage.vue both use RadioFilter.vue and are on different WP pages.

I'm wondering how to deploy this on different pages, either with different shortcodes or passing a param through the shortcode. How can I structure my codebase so I can benefit from reusable components while also having essentially 5 or 6 different apps to be injected?

Collapse
 
dgmann profile image
DGMANN • Edited

Hey Cole!

You could create a globals folder, where you can store all your global vue-components, stylings, extra scripts and so on. On the same level of the globals folder you can set up your different Vue instances. These can access the necessary global stuff.
Each Vue instance get a shortcode so that all instances can work independently. This makes sense if they are used on different pages. Otherwise you may have duplicate code.