Use eleventy to generate a single page application (solved). #2652
Unanswered
voorjaar
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Why
SPA has a better user experience, such as no need to refresh the page, no loss of scroll position. And you can add page switching animation and progress bar, etc.
Solution
I have created a plugin called eleventy-plugin-mtos for Eleventy to implement this functionality. It's based on mtos.
Preview
Checkout this page for a preview demo. You can compare it to the site without mtos configured.
How it works?
The mtos works similar to SPA, but is based on native DOM. The workflow like this:
<a>
elements which propertyhref
includes current host.onclick
function, when clicked, fetch the HTML content from target link.So basically you still serve the static HTML files, but the user experience is the same as SPA with incremental requests via fetch API. It's still an MPA, but it works like an SPA in client side.
Beta Was this translation helpful? Give feedback.
All reactions