-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Possibility to Define Vue 3 Plugins #689
Comments
I have released a draft for this. It uses a function called import { fromVue3, defineVue3Middleware } from 'piral-vue-3/convert';
import Page from './Page.vue';
import i18next from 'i18next';
import I18NextVue from 'i18next-vue';
import type { PiletApi } from 'sample-piral';
i18next.init({
lng: 'de',
interpolation: {
escapeValue: false
},
fallbackLng: false,
resources: {
en: {
translation: {
greeter: "Welcome",
},
},
de: {
translation: {
greeter: "Willkommen",
},
},
}
});
export function setup(app: PiletApi) {
defineVue3Middleware(vue => {
vue.use(I18NextVue, { i18next });
});
app.registerPage('/sample', fromVue3(Page));
} Here we integrate the (When not in a standalone pilet you can access the new What do you think about this design @achwilko ? Would that work? Anything to improve here? |
@FlorianRappl It's great! Many thanks for your work! 🍻 I'm just wondering, by defining the middleware with the provided callback, does it mean that we have also access to the Vue 3 Once again many thanks for your time and help. I am so happy to see this proposal provided so quickly :) |
Yes - this was the idea (otherwise I'd just have it called
Well, it depends. If you are using it "standalone" (as the example goes) you are making these plugins / middleware available to all components in the scope of the pilet. However, if you use this from a globally set up (i.e., pilet API extension) vue3 plugin you'll have this rolled out to all components. Rolling it out to all components may not be what you want. Also, right now only one callback is acceptable; I think I would rebuild it such it accepts many callbacks (multiple plugins would want to add something). The recommended way is the standalone way. |
Thanks @FlorianRappl for clarifications. The standalone approach is much much better in my opinion, so I would love to use it this way. Once again, many thanks! 🍻 |
Quick feedback @achwilko - have you tried the preview version? Does it work for you (or anything missing)? |
Hi @FlorianRappl wasn't aware of the preview version :) How can I get it (exact version)? |
It's using the |
Thanks @FlorianRappl , I've updated to use As an example, the below code is not working (
Where
|
No it should be fine. Any error message? |
@FlorianRappl Unfortunately, no errors (during build and console) so have no idea how to debug it. I was testing usage in one of the pilet but maybe I should create a new piral project from scratch? |
OK, started to work while using only 1 pilet, so let me verify :) |
Should be fine. Are your pilets standalone or are they based / assume that Vue comes with the app shell? |
It's working perfectly :) I've tested |
Great news - so it's working now with multiple pilets, too? All problems solved? |
Exactly, it's working with multiple pilets but I had to update
So all above pilets (current, mf2 and mf3) need to use |
New Feature Proposal
For more information, see the
CONTRIBUTING
guide.Description
Would be great to have the possibility to define and use desired plugins while using Vue 3 ( eg. via
piral-vue3/convert
). Documentation regarding Vue 3 plugin usage can be found below:Background
There are a lot of useful plugins for Vue 3 (eg. https://tanstack.com/query/latest/docs/framework/vue/installation#vue-query-initialization) or i18n (https://i18next.github.io/i18next-vue/guide/started.html#setup) so would be great to have a possibility to use them per pilet/team.
Discussion
Link to Discord thread:
The text was updated successfully, but these errors were encountered: