From 1ec5925cc71775c1cee14a73379ce8c5aef90ceb Mon Sep 17 00:00:00 2001 From: Thomas Cristina de Carvalho Date: Thu, 23 Nov 2023 15:28:20 -0500 Subject: [PATCH] Update page query to handle 404 if page doesn't exists Also update root error boundary --- templates/hydrogen-theme/app/qroq/queries.ts | 16 +++++++++++----- templates/hydrogen-theme/app/root.tsx | 11 ++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/templates/hydrogen-theme/app/qroq/queries.ts b/templates/hydrogen-theme/app/qroq/queries.ts index 27574dd..829cbec 100644 --- a/templates/hydrogen-theme/app/qroq/queries.ts +++ b/templates/hydrogen-theme/app/qroq/queries.ts @@ -13,11 +13,17 @@ import { */ export const PAGE_QUERY = q("*") .filter( - ` _type == "page" && - language in [$language, null] && - slug.current == $handle || - _type == "home" && - language in [$language, null] + ` ( + _type == "page" && + language in [$language, null] && + ($handle != "home" && slug.current == $handle) + ) || + ( + _type == "home" && + language in [$language, null] && + $handle == "home" && + !defined(slug.current) + ) ` ) .grab({ diff --git a/templates/hydrogen-theme/app/root.tsx b/templates/hydrogen-theme/app/root.tsx index 648cd8e..7244ef3 100644 --- a/templates/hydrogen-theme/app/root.tsx +++ b/templates/hydrogen-theme/app/root.tsx @@ -126,9 +126,10 @@ export async function loader({ context }: LoaderFunctionArgs) { export default function App() { const nonce = useNonce(); + const locale = useLocale(); return ( - + @@ -167,18 +168,18 @@ export function ErrorBoundary() { - {title} + - -
+ +

{title}

-
+