getcandy / hub

GetCandy v1 Hub built on Nuxt.js
30 stars 9 forks source link

target: 'static' #21

Open glennjacobs opened 3 years ago

glennjacobs commented 3 years ago

To allow static hosting, we probably need to include the following in the Nuxt config

  // Target (https://go.nuxtjs.dev/config-target)
  target: 'static',

This allows a Nuxt project to be generated for static hosting. I'm unsure how dynamic routes will cope with this, but having tested on a new plain Nuxt install it somehow handles dynamic routes, e.g. /pages/blog/_slug.vue

This gets away from the nasty 404.html issue and introduces a nice index.html file instead.

glennjacobs commented 3 years ago

Having done more research, this option generates an index.html file and also a 200.html file as a fallback.

However, Netlify for example, uses 404.html as the fallback.

We may need to offer a guide for this, rather than offer a one size fits all solution.

alecritson commented 3 years ago

Also I think a problem we're potentially going to have is that it generates the pages from the pages directory. Currently it's empty as each part of the hub is made up of external modules and plugins that register their own routes and pages.

Maybe there is a way to tell Nuxt to generate those as well, doesn't solve the dynamic issue as you said however.

Using the query string was mentioned before but not sure if this is worth the time and effort as we don't really know how people are deploying. Maybe a set of guides under a "Deployment" heading would be beneficial so we could provide multiple avenues to users.

glennjacobs commented 3 years ago

The only real thing I think it changes is whether it generates an index.html file and what the fallback is, ie. 200.html or 404.html.

As you say, pages won't get generated. Maybe we should add an index page so we get an index.html?

Netlify just runs off the 404.html page.