import React from 'react'; import { navigate, graphql, StaticQuery } from 'gatsby'; import { getUserLangKey } from 'ptz-i18n'; import { withTranslation, WithTranslation } from 'react-i18next'; import Seo from './Seo'; import PageLoading from './PageLoading'; class RedirectIndex extends React.PureComponent { langKey = ''; constructor(args: any) { super(args); // Skip build, Browsers only if (typeof window !== 'undefined') { const langKey = getUserLangKey(['zh', 'en'], 'zh'); this.langKey = langKey; // https://github.com/angeloocana/gatsby-plugin-i18n/issues/52#issuecomment-451590961 navigate(langKey); } } renderIndex = (data: { site: { siteMetadata: { title?: string; }; }; }) => { const { t } = this.props; const { site: { siteMetadata: { title = '' }, }, } = data; return ( <> ); }; render() { return ( ); } } export default withTranslation()(RedirectIndex);