import React from 'react';
import Index from '../components/IndexPage';
import graphql from 'graphql';
import { redirectToHome } from 'ptz-i18n';

class RedirectIndex extends React.PureComponent {
  constructor(args) {
    super(args);
    const { langs, defaultLangKey } = args.data.site.siteMetadata.languages;
    redirectToHome(langs, defaultLangKey);
  }

  render() {
    return (<Index {...this.props} />);
  }
}

export default RedirectIndex;

export const pageQuery = graphql`
  query IndexQuery {
    allMarkdownRemark(
      limit: 3
      sort: { fields: [frontmatter___date], order: DESC }
      filter: {
        frontmatter: { draft: { ne: true } },
        fields: { langKey: { regex: "/(en|any)/" } }
      },
    ) {
      edges {
        node{
          frontmatter{
            title,
            date
          },
          fields{
            slug,
            langKey
          },
          excerpt
        }
      }
    }
    site{
      siteMetadata{
        languages {
          defaultLangKey
          langs
        }
        resume{
          technologies{
            name,
            tags,
            level,
            years,
            img
          }
        }
      }
    }
  }
`;

@@ -24,53 +24,8 @@
 t';%0A
-import Index from '../components/IndexPage';%0A
 impo
@@ -339,29 +339,11 @@
 n (%3C
-Index %7B...this.props%7D
+div
  /%3E)
@@ -440,690 +440,103 @@
 ry %7B
-%0A
     
-allMarkdownRemark(%0A      limit: 3%0A      sort: %7B fields: %5Bfrontmatter___date%5D, order: DESC %7D%0A      filter: %7B%0A        frontmatter: %7B draft: %7B ne: true %7D %7D,%0A        fields: %7B langKey: %7B regex: %22/(en%7Cany)/%22 %7D %7D%0A      %7D,%0A    ) %7B%0A      edges %7B%0A        node%7B%0A          frontmatter%7B%0A            title,%0A            date%0A          %7D,%0A          fields%7B%0A            slug,%0A            langKey%0A          %7D,%0A          excerpt%0A        %7D%0A      %7D%0A    %7D%0A    site%7B%0A      siteMetadata%7B%0A        languages %7B%0A          defaultLangKey%0A          langs%0A        %7D%0A        resume%7B%0A          technologies%7B%0A            name,%0A            tags,%0A            level,%0A            years,%0A            img%0A          %7D
+%0A    site%7B%0A      siteMetadata%7B%0A        languages %7B%0A          defaultLangKey%0A          langs
 %0A   

Remove redirecting msg