-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1cff5ef
commit 494f71e
Showing
6 changed files
with
73 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
import styled from "styled-components" | ||
|
||
const StyledYouTube = styled.iframe` | ||
display: block; | ||
` | ||
|
||
const YouTube = ({id}) => { | ||
return ( | ||
<StyledYouTube | ||
title={id} | ||
width="560" | ||
height="315" | ||
src={`https://www.youtube-nocookie.com/embed/${id}`} | ||
frameBorder="0" | ||
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" | ||
allowFullScreen | ||
/> | ||
) | ||
} | ||
|
||
YouTube.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
} | ||
|
||
export default YouTube |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {useStaticQuery, graphql} from "gatsby" | ||
|
||
const useEpisode = () => { | ||
const query = graphql` | ||
{ | ||
allYoutubeVideo( | ||
limit: 1 | ||
sort: {fields: publishedAt, order: DESC} | ||
) { | ||
nodes { | ||
title | ||
videoId | ||
description | ||
localThumbnail { | ||
childImageSharp { | ||
fluid(maxWidth: 700) { | ||
...GatsbyImageSharpFluid | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
|
||
const data = useStaticQuery(query) | ||
|
||
const episode = data.allYoutubeVideo.nodes[0] | ||
|
||
// truncate description | ||
episode.description = episode.description.split("---")[0] | ||
|
||
return episode | ||
} | ||
|
||
export default useEpisode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters