Skip to content

Commit

Permalink
fix: possibly unset document title on client routing
Browse files Browse the repository at this point in the history
Before this fix, when client-side navigating to a
page that had no title, we forgot to unset
document.title

Similar to vikejs/vike-react#27
  • Loading branch information
lourot committed Oct 25, 2023
1 parent f206d94 commit 9358204
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions vike-solid/renderer/+onRenderClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,23 @@ const onRenderClient: OnRenderClientAsync = async (

const container = document.getElementById("page-view")!;
if (container.innerHTML !== "" && pageContext.isHydration) {
// Hydration
dispose = hydrate(() => getPageElement(pageContextStore)!, container);
} else {
// First rendering
dispose = render(() => getPageElement(pageContextStore)!, container);
}
rendered = true;
} else {
// Client routing
// See https://vike.dev/server-routing-vs-client-routing

setPageContext(reconcile(pageContext));
}

const title = getTitle(pageContext);
if (title !== null) {
document.title = title;
// Get the page's `title` config value, which may be different from the
// previous page. It can even be null, in which case we should unset the
// document title.
const title = getTitle(pageContext);
document.title = title || "";
}
}
};

0 comments on commit 9358204

Please sign in to comment.