From 832794e035705e7f0a5989ce240a385e5ccebf62 Mon Sep 17 00:00:00 2001 From: Kevin Hoerr Date: Mon, 28 Nov 2022 17:37:25 -0500 Subject: Reintegrate GraphQL (#23) * Use GraphQL for site metadata incl version * Explicit props for passthrough components --- src/hooks/SiteMetadata.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/hooks/SiteMetadata.ts (limited to 'src/hooks/SiteMetadata.ts') diff --git a/src/hooks/SiteMetadata.ts b/src/hooks/SiteMetadata.ts new file mode 100644 index 0000000..889f42b --- /dev/null +++ b/src/hooks/SiteMetadata.ts @@ -0,0 +1,21 @@ +import { useStaticQuery, graphql } from "gatsby"; + +type SiteMetadata = NonNullable< + NonNullable["siteMetadata"] +>; + +export const useSiteMetadata = (): SiteMetadata => { + const { site } = useStaticQuery(graphql` + query getSiteMetadata { + site { + siteMetadata { + author + description + title + } + } + } + `); + + return site?.siteMetadata ?? ({} as SiteMetadata); +}; -- cgit