Skip to content

Instantly share code, notes, and snippets.

@gaurangrshah
Created November 3, 2020 21:17
Show Gist options
  • Save gaurangrshah/7c55427d5cc2cbccf65a43da40034dae to your computer and use it in GitHub Desktop.
Save gaurangrshah/7c55427d5cc2cbccf65a43da40034dae to your computer and use it in GitHub Desktop.
#gatsby #hooks
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