For sure, here's the exact code I use to avoid the JSON error in a live Netlify + Sapper project. In this code I'm pulling in all posts through the prefetch and filtering, for me the filter was preventing Sapper from rendering any blog routes that were not loaded somewhere else. I put this code in the same file where my filter is but it can go in any .svelte file.
<divclass="sr-only"><!--You can iterate over the links from your preload fetch of posts-->
{#each posts as { slug, title }}
<arel="prefetch"href="blog/{ slug }">{title}</a>
{/each}
<!--And manually put any links that are breaking as well (it means Sapper doesn't think you're using them)--><arel="prefetch"href="/someotherpage">Some page name for screen readers (nobody else sees it)</a></div>
I'm using the class sr-only to hide from everyone but screen readers, there are plenty options for this class but the flavor I use in my global css is this.
For sure, here's the exact code I use to avoid the JSON error in a live Netlify + Sapper project. In this code I'm pulling in all posts through the prefetch and filtering, for me the filter was preventing Sapper from rendering any blog routes that were not loaded somewhere else. I put this code in the same file where my filter is but it can go in any .svelte file.
I'm using the class
sr-only
to hide from everyone but screen readers, there are plenty options for this class but the flavor I use in my global css is this.You might also want to put a heading on top of that list of links so it's not confusing for screen readers.