dfghgfhplkjbv

src/templates/Podcast.js

Mar 1st, 2019
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 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 SubscribeMain from 'src/components/Subscribe'
  6. import Footer from 'src/components/Footer'
  7. import Home from 'src/components/Home'
  8. import Header from 'src/components/Header'
  9. import NewsFeed from 'src/components/NewsFeed'
  10. import SinglePodcast from 'src/components/SinglePodcast'
  11. import withLocale from 'src/components/withLocale'
  12.  
  13. class PodcastTemplate extends Component {
  14. render() {
  15. const {
  16. data: {
  17. subscribe,
  18. podcast: {
  19. title,
  20. duration,
  21. guest,
  22. cover,
  23. podcast: { url: podcastFile },
  24. },
  25. news: { edges: newsEdges },
  26. },
  27. locale,
  28. } = this.props
  29.  
  30. const news = newsEdges.filter(({ node }) => node.slug !== '_')
  31.  
  32. return (
  33. <Layout locale={locale}>
  34. <LayoutHelmet locale={locale} />
  35. <main>
  36. <Header {...this.props} locale={locale} />
  37. <SinglePodcast
  38. title={title}
  39. podcast={podcastFile}
  40. duration={duration}
  41. podcastTitle={title}
  42. podcastGuest={guest}
  43. podcastCover={cover}
  44. locale={locale}
  45. />
  46. <NewsFeed news={news} locale={locale} />
  47. <Home onChangeData={this.props.onChangeData} locale={locale} />
  48. <SubscribeMain locale={locale} subscribe={subscribe} />
  49. </main>
  50. <Footer isInHome locale={locale} />
  51. </Layout>
  52. )
  53. }
  54. }
  55.  
  56. export const query = graphql`
  57. query Podcast($id: String!, $locale: String!) {
  58. podcast: datoCmsPodcast(id: { eq: $id }) {
  59. title
  60. duration
  61. publishDate
  62. cover {
  63. url
  64. id
  65. fluid(maxWidth: 400, imgixParams: { fm: "jpg", auto: "compress, format" }) {
  66. ...GatsbyDatoCmsFluid
  67. }
  68. }
  69. guest
  70. podcast {
  71. url
  72. }
  73. slug
  74. }
  75. news: allDatoCmsNews(
  76. filter: { ismain: { eq: true }, locale: { eq: $locale } }
  77. sort: { fields: [publishdate], order: DESC }
  78. limit: 3
  79. ) {
  80. edges {
  81. node {
  82. publishdate
  83. slug
  84. title
  85. description
  86. ismain
  87. image {
  88. id
  89. fluid(maxWidth: 1240, imgixParams: { fm: "jpg", auto: "compress, format" }) {
  90. ...GatsbyDatoCmsFluid
  91. }
  92. }
  93. author
  94. }
  95. }
  96. }
  97. subscribe: file(relativePath: { eq: "subscribe-illustration.jpeg" }) {
  98. childImageSharp {
  99. fluid(maxWidth: 1440) {
  100. ...GatsbyImageSharpFluid
  101. }
  102. }
  103. }
  104. }
  105. `
  106.  
  107. export default withLocale(PodcastTemplate)
Add Comment
Please, Sign In to add comment