import React, { useState, useEffect } from "react" import { Helmet } from "react-helmet" const Seo = ({location}) => { const [refreshContent, setRefreshContent] = useState() useEffect(() => { if (location.host.endsWith("gatsbyjs.io")) { const urlRedirect = `http://example.com${location.pathname}${location.search}` setRefreshContent(`0;URL="${urlRedirect}"`) } else { setRefreshContent(undefined) } }, [location]) let metaDatas = [ { property: "og:site_name", content: "xxxxx", }, { property: "og:locale", content: "ja", }, 中略 ] if (refreshContent !== undefined) { metaDatas = metaDatas.concat([ { "http-equiv": "refresh", content: refreshContent, }, ]) } return ( ) } export default Seo