dfghgfhplkjbv

src/components/Home/Home.js

Mar 1st, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. import React, { Component } from 'react'
  2. import { graphql } from 'gatsby'
  3. import Layout from 'src/components/Layout'
  4. import LayoutHelmet from 'src/components/LayoutHelmet'
  5. import Hot from 'src/components/Hot'
  6. import NewsFeed from 'src/components/NewsFeed'
  7. import SubscribeMain from 'src/components/Subscribe'
  8. import Footer from 'src/components/Footer'
  9. import Home from 'src/components/Home'
  10. import Jobs from 'src/components/Jobs'
  11. import withLocale from 'src/components/withLocale'
  12.  
  13. class HomeTemplate extends Component {
  14. render() {
  15. const {
  16. data: {
  17. news: { edges: newsEdges },
  18. interviews: { edges: interviewsEdges },
  19. jobTags: { edges: jobTags },
  20. offers: { edges: offers },
  21. subscribe,
  22. },
  23. locale,
  24. changeLocale,
  25. } = this.props
  26.  
  27. const prepareNews = (news) => news.filter(({ node }) => node.slug !== '_')
  28. const news = prepareNews(newsEdges)
  29.  
  30. return (
  31. <Layout locale={locale}>
  32. <LayoutHelmet locale={locale} />
  33. <main>
  34. <Hot article={interviewsEdges[0]} locale={locale} changeLocale={() => changeLocale()} />
  35. <NewsFeed news={news} locale={locale} />
  36. <Home onChangeData={this.props.onChangeData} locale={locale} news={news} interviews={interviewsEdges} />
  37. <Jobs jobTags={jobTags} offers={offers} locale={locale} />
  38. <SubscribeMain locale={locale} subscribe={subscribe} />
  39. </main>
  40. <Footer locale={locale} />
  41. </Layout>
  42. )
  43. }
  44. }
  45.  
  46. export const query = graphql`
  47. query HomePage($locale: String!) {
  48. interviews: allDatoCmsInterview(filter: { locale: { eq: $locale } }) {
  49. edges {
  50. node {
  51. title
  52. description
  53. author
  54. photographer
  55. publishDate
  56. image {
  57. url
  58. fluid(maxWidth: 1240, imgixParams: { fm: "jpg", auto: "compress, format" }) {
  59. ...GatsbyDatoCmsFluid
  60. }
  61. }
  62. podcast {
  63. podcastTitle
  64. podcastGuest
  65. podcastCover {
  66. id
  67. fluid(maxWidth: 400, imgixParams: { fm: "jpg", auto: "compress, format" }) {
  68. ...GatsbyDatoCmsFluid
  69. }
  70. }
  71. duration
  72. podcast {
  73. url
  74. }
  75. }
  76. summary {
  77. title
  78. description
  79. }
  80. bodyNode {
  81. childMarkdownRemark {
  82. html
  83. }
  84. }
  85. slug
  86. }
  87. }
  88. }
  89. news: allDatoCmsNews(
  90. filter: { ismain: { eq: true }, locale: { eq: $locale } }
  91. sort: { fields: [publishdate], order: DESC }
  92. limit: 3
  93. ) {
  94. edges {
  95. node {
  96. publishdate(formatString: "DD.MM.YYYY")
  97. slug
  98. title
  99. description
  100. ismain
  101. image {
  102. id
  103. fluid(maxWidth: 1240, imgixParams: { fm: "jpg", auto: "compress, format" }) {
  104. ...GatsbyDatoCmsFluid
  105. }
  106. }
  107. author
  108. }
  109. }
  110. }
  111. jobTags: allDatoCmsJobTag(filter: { locale: { eq: $locale } }) {
  112. edges {
  113. node {
  114. title
  115. locale
  116. id
  117. }
  118. }
  119. }
  120. offers: allDatoCmsJob(filter: { locale: { eq: $locale } }) {
  121. edges {
  122. node {
  123. locale
  124. id
  125. description
  126. companyName
  127. companyLogo {
  128. url
  129. }
  130. tag {
  131. id
  132. title
  133. }
  134. slug
  135. }
  136. }
  137. }
  138. subscribe: file(relativePath: { eq: "subscribe-illustration.jpeg" }) {
  139. childImageSharp {
  140. fluid(maxWidth: 1440) {
  141. ...GatsbyImageSharpFluid
  142. }
  143. }
  144. }
  145. }
  146. `
  147.  
  148. export default withLocale(HomeTemplate)
Add Comment
Please, Sign In to add comment