diff --git a/gatsby-node.js b/gatsby-node.js index c8d934c..545451a 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -2,7 +2,7 @@ const path = require('path') exports.createPages = async ({ actions, graphql }) => { const {createPage} = actions; - + const result = await graphql(` { courses: allMarkdownRemark( @@ -46,7 +46,7 @@ exports.createPages = async ({ actions, graphql }) => { courses.forEach(({node}) => { createPage({ path: node.frontmatter.path, - component: courseTemplate + component: courseTemplate, }) }); diff --git a/src/components/templates/courseTemplate.js b/src/components/templates/courseTemplate.js index 6e472d4..9b211ca 100644 --- a/src/components/templates/courseTemplate.js +++ b/src/components/templates/courseTemplate.js @@ -1,29 +1,52 @@ import React from "react" -import { Link, graphql } from "gatsby" +import { graphql } from "gatsby" +import { FormattedMessage, Link, useIntl, injectIntl } from "gatsby-plugin-intl" +import SEO from "../seo" import Layout from "../layout" -export default function Template({data}){ - const {markdownRemark: course} = data; +const Template = (props) => { + const intl = useIntl() + const lang = intl.locale + const course = props.data.course + console.log(course) + let par = 'Физика' - switch (course.frontmatter.parent) { - case 'education': - par = 'Образование'; - break; - case 'math': - par = 'Математика'; - break; - case 'software': - par = 'Программное обеспечение'; - break; - default: - par = 'Физика'; + if (lang == "ru"){ + switch (course.frontmatter.parent) { + case 'education': + par = 'Образование'; + break; + case 'math': + par = 'Математика'; + break; + case 'software': + par = 'Программное обеспечение'; + break; + default: + par = 'Физика'; + }} + else { + switch (course.frontmatter.parent) { + case 'education': + par = 'Education'; + break; + case 'math': + par = 'Maths'; + break; + case 'software': + par = 'Software'; + break; + default: + par = 'Physics'; + } } return( - + +