sunbeam.city is one of the many independent Mastodon servers you can use to participate in the fediverse.
Sunbeam City is a anticapitalist, antifascist solarpunk instance that is run collectively.

Administered by:

Server stats:

90
active users

notplants

curious what the most minimal ssg or front-end framework is for client-side switching between pages without a full reload?

also not sure what the technical term for that is

i’ve a couple sites built with gastby such as canalswans.commoninternet.net but all of react feels like overkill

canalswans.commoninternet.netcanalswans.commoninternet.netan online-retail-conglomerate maintained by Max Fowler

@notplants like in my head, javascript code instructing links to just change the main part of the page and not the rest of it, seems like something one could do in a file or two

@notplants @decentral1se @j12i got a version working today using 87 lines of plain javascript codeberg.org/notplants/thimble

more optimizations could be possible via using gzip, or maybe storing prefetched pages using javascript variables would be faster than using the cache (?) but I kind of like that this could be subbed into any static site without making any other modifications to it

Codeberg.orgthimble-switcherthe world's most minimal single-page-application front-end framework

@notplants @decentral1se @j12i

Very cool tbh 👀

line 84 (error handler) should probably do something to emulate clicking on the link and having it navigate normally. Because otherwise a missing cache entry on-click will result in a silent failure for the user.

@notplants @decentral1se @j12i

Might wanna do the same thing on line 81 as an `else` statement for `if (newMainContent) {`, to handle all cases.

Really don't wanna get into a situation where user clicks a link and nothing happens.

@notplants @decentral1se @j12i

Ideally you could delay calling `event.preventDefault();` until after you know that the quick-nav was successful. But due to the async nature of the cache and fetch mechanic, i don't think thats possible.

also appreciating that because its a small piece of code, we actually have a decent chance of finding all possible bugs

when I was using gatsby often builds would get the most random and cryptic errors. a lot of clear the cache rm -r node_modules reinstall and then problem is gone

thanks for the code review @forestjohnson I appreciate it, and wouldn't have thought of those error conditions -- agreed having a link not do anything would suck, and emulating the default behavior when there was an error makes sense