Created
November 3, 2020 21:17
-
-
Save gaurangrshah/7c55427d5cc2cbccf65a43da40034dae to your computer and use it in GitHub Desktop.
#gatsby #hooks
This file contains hidden or 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 { graphql, useStaticQuery } from "gatsby" | |
type Props = { | |
site: { | |
siteMetadata: { | |
title: string | |
tagline: string | |
description: string | |
language: string | |
siteUrl: string | |
author: string | |
pages: { | |
label: string | |
path: string | |
} | |
socialLinks: { | |
label: string | |
path: string | |
} | |
brandColors: { | |
key: string | |
} | |
[key: string]: unknown | |
} | |
} | |
file: { | |
publicURL: string | |
} | |
} | |
const useSiteMetadata = () => { | |
const data = useStaticQuery<Props>(graphql` | |
query { | |
site { | |
siteMetadata { | |
title | |
tagline | |
description | |
language | |
siteUrl | |
author | |
pages { | |
label | |
path | |
} | |
socialLinks { | |
label | |
path | |
} | |
brandColors { | |
primary | |
secondary | |
} | |
} | |
} | |
file(name: { eq: "fingers-star" }) { | |
publicURL | |
} | |
} | |
`) | |
return { ...data?.site?.siteMetadata, image: data?.file?.publicURL } | |
} | |
export default useSiteMetadata |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment