headstartwp
headstartwp copied to clipboard
update currentSite to match 404 and 500 pages
404 and 500 pages do not sit under the _sites/[site]
middleware so do not have access to the query param. The site can be set here with the window.location.host
value instead.
const currentSite = useMemo(() => {
if (router.query?.site && !Array.isArray(router.query.site)) {
return getSiteByHost(router.query.site, router.locale);
}
// 404.js and 500.js do not have a site query param.
if (typeof window !== 'undefined') {
return getSiteByHost(window.location.host, router.locale);
}
return {};
}, [router]);