egoist / docute

📚 Effortless documentation, done right.
https://docute.egoist.dev
MIT License
3.8k stars 427 forks source link

Prerendered site will re-fetch md #207

Closed jthegedus closed 5 years ago

jthegedus commented 5 years ago

Using presite to create static html of a Docute site is great, except I have found that each route has

    <script>
      new Docute({
        target: "#docute",
        ...
      });
    </script>

which means that when the HTML finishes loading, Docute will re-fetch the .md for the particular route and re-mount it to the target: "#docute" div.

This creates two issues:

  1. there is a flash of loaded content, then Docute loading visual, then the newly computed content.
  2. the content is fetched from the network again.

I'm not sure where a flag would go to stop this from occurring, but an option like so would be nice:

    <script>
      new Docute({
        target: "#docute",
         fetchContent: false,
        ...
      });
    </script>

I've tried removing the new Docute script from the presite output HTML, but this causes the issues with dynamic features like toggling light/dark theme.

Related: #34, #174

egoist commented 5 years ago

https://github.com/leptosia/docute/commit/1b02d0f063db00bc357542b5c0bb7d0dd70cfc5c

this commit adds pre-render support, kinda like the way Vue SSR works:

you need to re-install presite since I updated the user agent there.


the generated html is kinda large tho, something needs to be done to reduce the size.

jthegedus commented 5 years ago

@egoist cheers, I'll give it a go.

jthegedus commented 5 years ago

Thanks for your work on this. It fixes the re-fetching :tada: so I will close this issue.

But I do wish to flag that I still see a flash of the content-loading animation sometimes when changing routes. I'm unsure what the cause is other than the router always displaying this while checking the cache for data.