website-v2 icon indicating copy to clipboard operation
website-v2 copied to clipboard

Describe static site behaviour better in documentation

Open davydnorris opened this issue 5 years ago • 3 comments
trafficstars

Is your feature request related to a problem? Please describe.

I am using nuxt in static mode to generate my web site, and recently added a footer to provide cookie usage information. I am using the browser's localStorage to save the user's acceptance and privacy settings, and a v-if to hide the footer if they have accepted the info.

I've added the code into the footer itself, reading and setting the localStorage during initialisation, and this works fine in dev mode and in mixed mode, but fails in full static mode. Right now I can't quite work it out but it looks as though both my asyncData and fetch calls get rendered away during static rendering, but create or mount are still there - however, the v-if statement is triggered during render and it messes up the display of the footer.

I'm still stuck trying to get a simple footer to display or not based on localStorage in the browser

Describe the solution you'd like

The nuxt lifecycle is beautifully documented for the situation where you're running in SSR or universal rendered mode, but this doesn't seem to be the same lifecycle that ends up in a statically rendered site. It would be incredibly helpful if there was more documentation around how a statically rendered site works.

Describe alternatives you've considered

working it out myself

Additional context

none

davydnorris avatar Oct 11 '20 00:10 davydnorris

I agree. Would love to know more about how static works and best practices for using it.

drewbaker avatar Oct 11 '20 14:10 drewbaker

Just been bitten by the static generation again - apparently the fetch() function never makes it into the static site :-(

Where are you supposed to put code that accesses dynamic content within static pages?

davydnorris avatar Oct 12 '20 06:10 davydnorris

Just been bitten by the static generation again - apparently the fetch() function never makes it into the static site :-(

Where are you supposed to put code that accesses dynamic content within static pages?

@davydnorris

You're able to set fetchOnServer: false in your components to disable it running when being statically generated.

Skye-31 avatar Oct 26 '20 12:10 Skye-31