Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update page query to handle 404 if page doesn't exists #16

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions templates/hydrogen-theme/app/qroq/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
11 changes: 6 additions & 5 deletions templates/hydrogen-theme/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ export async function loader({ context }: LoaderFunctionArgs) {

export default function App() {
const nonce = useNonce();
const locale = useLocale();

return (
<html lang="en">
<html lang={locale?.language}>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
Expand Down Expand Up @@ -167,18 +168,18 @@ export function ErrorBoundary() {
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>{title}</title>
<Meta />
<Fonts />
<Links />
</head>
<body>
<main>
<body className="flex min-h-screen flex-col [&_main]:flex-1">
<Layout>
<section>
<div className="container">
<h1>{title}</h1>
</div>
</section>
</main>
</Layout>
<ScrollRestoration nonce={nonce} />
<Scripts nonce={nonce} />
<LiveReload nonce={nonce} />
Expand Down