slinkity / slinkity

To eleventy and beyond! The all-in-one tool for templates where you want them, component frameworks where you need them 🚀

Home Page:https://slinkity.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-hydrated component shortcodes cause unnecessary HTML code in build

hippotastic opened this issue · comments

commented

Describe the bug

When building pages that include component shortcodes without any hydrate prop, the resulting HTML code contains unnecessary <slinkity-mount-point> wrappers around the purely static components, as well as data-reactroot="" props on the component's root elements.

If components are used extensively on a page, this behavior generates a lot of additional markup that does not serve any purpose for the end user and makes the HTML code appear less clean.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Slinkity project using npm init slinkity.
  2. In the contained index.md, change the line {% component "Slinky.jsx", hydrate="eager" %} to {% component "Slinky.jsx" %}.
  3. Run npm run build.
  4. Open the generated _site/index.html and look for the Slinky HTML output.

Expected HTML output

<section class="slinky__container"><!-- Slinky SVG etc. --></section>

Actual HTML output

<slinkity-mount-point data-s-id="0"><section class="slinky__container" data-reactroot=""><!-- Slinky SVG etc. --></section></slinkity-mount-point>

This will be removed for the 1.0 canary! Stay tuned 😁

Resolved in 1.0 canary 👍

commented

Great work, Ben! Many thanks for fixing this! Who doesn't love some clean markup?