diff --git a/src/components/Post/PostMeta.tsx b/src/components/Post/PostMeta.tsx
index 1e323304..427e5109 100644
--- a/src/components/Post/PostMeta.tsx
+++ b/src/components/Post/PostMeta.tsx
@@ -3,17 +3,19 @@ import { Link } from 'gatsby'
import Time from 'react-time'
import slugify from 'slugify'
import styles from './PostMeta.module.scss'
+import { useSiteMetadata } from '../../hooks/use-site-metadata'
-const PostMeta = ({ post, meta }: { post: any; meta: any }) => {
+const PostMeta = ({ post }: { post: any }) => {
const { author, updated, tags, type } = post.frontmatter
+ const siteMeta = useSiteMetadata()
const { date } = post.fields
return (
)
diff --git a/src/components/molecules/Subscribe.tsx b/src/components/molecules/Subscribe.tsx
index f5bf3b31..c0e2aa2b 100644
--- a/src/components/molecules/Subscribe.tsx
+++ b/src/components/molecules/Subscribe.tsx
@@ -1,22 +1,10 @@
import React from 'react'
-import { graphql, useStaticQuery } from 'gatsby'
import IconLinks from './IconLinks'
import styles from './Subscribe.module.scss'
-
-const query = graphql`
- query {
- site {
- siteMetadata {
- rss
- jsonfeed
- }
- }
- }
-`
+import { useSiteMetadata } from '../../hooks/use-site-metadata'
export default function Subscribe() {
- const data = useStaticQuery(query)
- const { rss, jsonfeed } = data.site.siteMetadata
+ const { rss, jsonfeed } = useSiteMetadata()
const links = [rss, jsonfeed]
return (
diff --git a/src/components/molecules/Vcard.tsx b/src/components/molecules/Vcard.tsx
index 0a37d908..68a5765e 100644
--- a/src/components/molecules/Vcard.tsx
+++ b/src/components/molecules/Vcard.tsx
@@ -3,21 +3,10 @@ import { graphql, useStaticQuery } from 'gatsby'
import Img from 'gatsby-image'
import IconLinks from './IconLinks'
import styles from './Vcard.module.scss'
+import { useSiteMetadata } from '../../hooks/use-site-metadata'
const query = graphql`
query {
- site {
- siteMetadata {
- author {
- name
- uri
- twitter
- github
- facebook
- }
- }
- }
-
avatar: allFile(filter: { name: { eq: "avatar" } }) {
edges {
node {
@@ -34,7 +23,7 @@ const query = graphql`
export default function Vcard() {
const data = useStaticQuery(query)
- const { twitter, github, facebook, name, uri } = data.site.siteMetadata.author
+ const { twitter, github, facebook, name, uri } = useSiteMetadata().author
const avatar = data.avatar.edges[0].node.childImageSharp.fixed
const links = [twitter, github, facebook]
diff --git a/src/components/organisms/Footer.tsx b/src/components/organisms/Footer.tsx
index 28c37536..99209568 100644
--- a/src/components/organisms/Footer.tsx
+++ b/src/components/organisms/Footer.tsx
@@ -1,6 +1,4 @@
-import React, { PureComponent } from 'react'
-import { StaticQuery, graphql } from 'gatsby'
-
+import React, { useState } from 'react'
import Container from '../atoms/Container'
import Vcard from '../molecules/Vcard'
import Subscribe from '../molecules/Subscribe'
@@ -10,85 +8,48 @@ import { ReactComponent as Github } from '../../images/github.svg'
import { ReactComponent as Bitcoin } from '../../images/bitcoin.svg'
import styles from './Footer.module.scss'
+import { useSiteMetadata } from '../../hooks/use-site-metadata'
-const query = graphql`
- query {
- site {
- siteMetadata {
- author {
- name
- uri
- bitcoin
- github
- }
- }
- }
- }
-`
+export default function Footer() {
+ const { name, uri, bitcoin, github } = useSiteMetadata()
+ const year = new Date().getFullYear()
+ const [showModal, setShowModal] = useState(false)
-export default class Footer extends PureComponent<
- {},
- { year: number; showModal: boolean }
-> {
- state = {
- year: null,
- showModal: false
+ const toggleModal = () => {
+ setShowModal(!showModal)
}
- toggleModal = () => {
- this.setState({ showModal: !this.state.showModal })
- }
+ return (
+