Svelte target ID mismatch: hardcoded svekyll-app vs shortcode svekyll-app-{slug} #17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The template main.js hardcodes 'svekyll-app' as the Svelte mount target, but Hugo shortcodes generate IDs like 'svekyll-app-{slug}'. This causes: Uncaught TypeError: can't access property '$$', i is undefined.
Why a wildcard fallback isn't enough
A naive fix using
querySelectorAll('[id^="svekyll-app-"]')[0]would only mount the first Svelte app on a page, breaking pages with multiple svekyll posts.Proper fix
Sprinkyll now replaces a
SPRINKYLL_TARGET_IDplaceholder in main.js with the correct slug-specific ID at build time. Each svekyll bundle gets its own hardcoded target ID, so multiple Svelte apps per page work correctly.PR: #18