dfghgfhplkjbv

src/templates/Home.js

Feb 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. import React 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.  
  12. // const prepareArticles = (interviews) => {
  13. // if (!interviews) return []
  14. // const { edges } = interviews
  15. // return edges.map(
  16. // ({
  17. // node: {
  18. // fields: { slug },
  19. // frontmatter: {
  20. // description,
  21. // publishDate,
  22. // title,
  23. // image,
  24. // templateKey,
  25. // podcast,
  26. // podcastTitle,
  27. // podcastCover,
  28. // podcastGuest,
  29. // },
  30. // },
  31. // }) => {
  32. // const preparedParticipant = {
  33. // slug,
  34. // description,
  35. // publishDate,
  36. // title,
  37. // templateKey,
  38. // podcast,
  39. // podcastTitle,
  40. // podcastCover,
  41. // podcastGuest,
  42. // }
  43. // if (image) {
  44. // preparedParticipant.image = image
  45. // }
  46. // return preparedParticipant
  47. // },
  48. // )
  49. // }
  50.  
  51. const HomeTemplate = (props) => {
  52. const {
  53. data: {
  54. news,
  55. page,
  56. interviews: { edges },
  57. },
  58. pageContext: { locale },
  59. } = props
  60. return (
  61. <Layout locale={locale}>
  62. <LayoutHelmet locale={locale} />
  63. <main>
  64. <Hot article={edges[0]} locale={locale} translations={page.fields.translations} />
  65. <NewsFeed news={news} locale={locale} />
  66. <Home onChangeData={props.onChangeData} locale={locale} />
  67. <Jobs />
  68. <SubscribeMain locale={locale} />
  69. </main>
  70. <Footer locale={locale} />
  71. </Layout>
  72. )
  73. }
  74.  
  75. export const query = graphql`
  76. query HomePage($locale: String!) {
  77. page: markdownRemark(frontmatter: { templateKey: { eq: "Home" } }) {
  78. fields {
  79. translations {
  80. lang
  81. url
  82. }
  83. }
  84. }
  85. interviews: allDatoCmsInterview(filter: { locale: { eq: $locale } }) {
  86. edges {
  87. node {
  88. description
  89. publishDate
  90. title
  91. image {
  92. id
  93. fluid(maxWidth: 1240, imgixParams: { fm: "jpg", auto: "compress" }) {
  94. ...GatsbyDatoCmsFluid
  95. }
  96. }
  97. podcast {
  98. podcastTitle
  99. podcastCover {
  100. url
  101. }
  102. podcast {
  103. url
  104. }
  105. podcastGuest
  106. }
  107. slug
  108. }
  109. }
  110. }
  111. news: allDatoCmsNews(
  112. filter: { ismain: { eq: true }, locale: { eq: $locale } }
  113. sort: { fields: [publishdate], order: DESC }
  114. limit: 3
  115. ) {
  116. edges {
  117. node {
  118. publishdate
  119. slug
  120. title
  121. description
  122. ismain
  123. image {
  124. id
  125. fluid(maxWidth: 1240, imgixParams: { fm: "jpg", auto: "compress" }) {
  126. ...GatsbyDatoCmsFluid
  127. }
  128. }
  129. author
  130. }
  131. }
  132. }
  133. }
  134. `
  135.  
  136. export default HomeTemplate
Advertisement
Add Comment
Please, Sign In to add comment