diff --git a/src/components/templates/news.js b/src/components/templates/news.js
index 428ffd9..ba0051c 100644
--- a/src/components/templates/news.js
+++ b/src/components/templates/news.js
@@ -1,38 +1,48 @@
import React from 'react'
-import { Link, graphql } from 'gatsby'
+import { graphql } from 'gatsby'
+import { FormattedMessage, Link, useIntl, injectIntl } from "gatsby-plugin-intl"
import { Timeline, TimelineItem } from 'vertical-timeline-component-for-react'
import Header from "../header"
import Footer from "../footer"
-export default function(props) {
- const news = props.data.news.edges.map(newsItem => newsItem.node)
+const NewsTemplate = ( props ) => {
+ const intl = useIntl()
+ const lang = intl.locale
+ console.log(lang)
+
+ var news = ""
+ if ( lang==="ru" ) { news = props.data.ru_news.edges}
+ else if ( lang==="en" ) { news = props.data.en_news.edges; }
+
const next = props.pageContext.next
const prev = props.pageContext.prev
+ console.log(news)
+
return (
<>
{/* Все новости
*/}
- {news.map(newsItem => (
+ {news.map(({node}) => (
- {newsItem.frontmatter.title}
-
+ {node.frontmatter.title}
+
))}
- {next &&
--->
}
+ {next && --->
}
@@ -40,24 +50,44 @@ export default function(props) {
)
}
+export default injectIntl(NewsTemplate)
+
export const query = graphql`
query NewsQuery($limit: Int!, $skip: Int!) {
- news: allMarkdownRemark(
- filter: {frontmatter: {content_type: {eq: "post"}, published: {eq: true}}},
+ ru_news: allMarkdownRemark(
+ filter: {frontmatter: {content_type: {eq: "post"}, published: {eq: true}, language: {eq: "ru"}}},
sort: {fields: [frontmatter___date], order: DESC},
limit: $limit
skip: $skip
- ) {
- edges {
- node {
- frontmatter {
- title
- slug
- date(formatString: "DD.MM.YYYY")
+ ) {
+ edges {
+ node {
+ frontmatter {
+ title
+ slug
+ date(formatString: "DD.MM.YYYY")
+ }
+ html
+ }
+ }
+ }
+
+ en_news: allMarkdownRemark(
+ filter: {frontmatter: {content_type: {eq: "post"}, published: {eq: true}, language: {eq: "en"}}},
+ sort: {fields: [frontmatter___date], order: DESC},
+ limit: $limit
+ skip: $skip
+ ) {
+ edges {
+ node {
+ frontmatter {
+ title
+ slug
+ date(formatString: "DD.MM.YYYY")
+ }
+ html
}
- html
}
}
- }
}
`