Last active
November 15, 2022 18:14
-
-
Save cavellblood/4607d4f0efe0b52565508a87fbf85824 to your computer and use it in GitHub Desktop.
Marketing Page for Hydrogen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groq from 'groq'; | |
import useSanityQuery from '~/hooks/useSanityQuery'; | |
export default function MarketingOverview({params, response}) { | |
response.doNotStream(); | |
const {handle} = params; | |
const {data: entry} = useSanityQuery({ | |
query: QUERY_SANITY, | |
params: {slug: handle}, | |
}); | |
if (!entry) { | |
if (response) { | |
response.status = 404; | |
} | |
console.log(response); | |
return 'not found'; | |
} | |
return ( | |
<div> | |
<h1>{entry.title}</h1> | |
</div> | |
); | |
} | |
const QUERY_SANITY = groq` | |
*[ | |
_type == 'marketingOverview' | |
&& slug.current == $slug | |
][0]{ | |
title, | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment