Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/routes/(_)tutorial/[[id]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Errored,
For,
Loading,
onSettled,
Show,
untrack,
} from "solid-js";
Expand Down Expand Up @@ -115,6 +116,12 @@ export default function Tutorial() {
// Old solidjs.com lesson ids render their new lesson; the host redirects them.
const id = () => canonicalTutorialId(params.id || firstTutorialId);
const solved = () => new URLSearchParams(location.search).has("solved");
// The page is prerendered without the query, so the button follows it only after hydration.
const [hydrated, setHydrated] = createSignal(false);
onSettled(() => {
setHydrated(true);
});
const showSolved = () => hydrated() && solved();
const index = () =>
tutorialDirectory.findIndex((entry) => entry.internalName === id());
const entryAt = (i: number) => {
Expand Down Expand Up @@ -186,9 +193,9 @@ export default function Tutorial() {
>
<a
class="rounded-lg bg-blue-600 px-3 py-1.5 font-semibold text-white hover:bg-blue-700"
href={`/tutorial/${id()}${solved() ? "" : "?solved"}`}
href={`/tutorial/${id()}${showSolved() ? "" : "?solved"}`}
>
{solved() ? "Reset" : "Solve"}
{showSolved() ? "Reset" : "Solve"}
</a>
<div class="flex gap-4">
<Show when={previous()}>
Expand Down
Loading