kevinmarrec / nuxt-pwa-module

⚠️ DEPRECATED ⚠️ Zero config PWA solution for Nuxt 3
MIT License
338 stars 32 forks source link

Per page manifest settings #17

Closed soylomass closed 1 year ago

soylomass commented 2 years ago

Is it possible to use a different start_url and scope parameters per page? A web-games website does this so that each game can be installed separately. Is this possible to do with this plugin?

Thanks in advance.

kevinmarrec commented 2 years ago

Hi @soylomass , this is not possible at the moment but we may think about an implementation that would make it possible :)

soylomass commented 2 years ago

Thanks for your answer @kevinmarrec . Could you guide me a bit on where to start if I'd try to implement this myself?

kevinmarrec commented 2 years ago

@soylomass I would tell you first to fully understand the base implementation of the module here. Especially the manifest (creation of manifest json) & meta (injection of manifest in meta tags) parts.

For now, the manifest json meta is added at root level, using the property app.head of Nuxt configuration to configure root head. By root I mean it will be added on all pages.

Then, the idea is to to use useHead Nuxt 3 composable to inject the manifest meta tag of a custom (per page) mannifest json.

But to generate these manifest json with different start_url and scope parameters per page, I think it will need https://v3.nuxtjs.org/guide/features/server-routes#server-middleware to serve a on-demand manifest.json based on the page you're on.

That said, AFAIK it's possible, but complex.

kevinmarrec commented 2 years ago

Hey @soylomass

I've implemented on-demand manifest.json through https://github.com/kevinmarrec/nuxt-pwa-module/commit/fa800723f86de346343a4ea434346d79beda6989

The server route is simple as serving a Javascript object : https://github.com/kevinmarrec/nuxt-pwa-module/blob/main/src/parts/manifest/handler.ts

We could think about using something like this for your case, but we'll also need to find out how to determine which part of your app is requesting manifest.json.

But for web-games website, it would need specific assets (icons/splash) for each game in addition to custom manifest.json.

It would make things complex :)

kevinmarrec commented 1 year ago

Hi @soylomass,

I've been thinking couple of hours on this feature, and my opion is that this is too much complex. More than generate a manifest.json on demand, it also means generating icons for each possible result, but also other things...

This has complexity on multiple levels.

So, unfortunately, I'm gonna close this issue as not planned.

Thank you in advance for your understanding :)