2021-10-11 13:50:24 +00:00
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
import { h, Fragment } from 'preact'
|
|
|
|
import { useState, useEffect } from 'preact/hooks'
|
|
|
|
import { isFuture, isPast } from 'date-fns'
|
|
|
|
import striptags from 'striptags'
|
|
|
|
|
|
|
|
import { H1 } from '../../components/Text'
|
|
|
|
import Markdown from '../../components/Markdown'
|
2021-10-11 17:15:09 +00:00
|
|
|
import translations from '../../data/strings'
|
2021-10-11 13:50:24 +00:00
|
|
|
import InfoLayout from '../../components/InfoLayout'
|
|
|
|
import VideoEmbed from '../../components/VideoEmbed'
|
|
|
|
import {
|
2021-10-11 17:15:09 +00:00
|
|
|
EpisodeCard,
|
2021-10-11 13:50:24 +00:00
|
|
|
Title,
|
|
|
|
InfoContent,
|
|
|
|
PositionedCross as CrossSvg,
|
|
|
|
Row,
|
|
|
|
ActionButton as Button,
|
|
|
|
Trailer,
|
|
|
|
} from './styles'
|
|
|
|
|
|
|
|
import intro from '../../data/intro.md'
|
|
|
|
// import credits from '../../data/credits.md'
|
|
|
|
|
|
|
|
import config from '../../data/config'
|
|
|
|
import trailerThumb from '../../assets/img/main_thumb.png'
|
|
|
|
|
|
|
|
const SeriesPage = ({ data }) => {
|
|
|
|
const trailerUrl = `https://www.youtube-nocookie.com/embed/${config.seriesTrailerId}?autoplay=1&vq=hd1080`
|
|
|
|
const [embedURL, setEmbedUrl] = useState('')
|
|
|
|
|
|
|
|
const onClickTrailerButton = () => {
|
|
|
|
setEmbedUrl(trailerUrl)
|
|
|
|
}
|
|
|
|
const deactivateEmbed = () => {
|
|
|
|
setEmbedUrl('')
|
|
|
|
}
|
|
|
|
|
2021-10-11 17:15:09 +00:00
|
|
|
console.log({ past: data.episodes.past, future: data.episodes.future })
|
2021-10-11 13:50:24 +00:00
|
|
|
|
2021-10-11 17:15:09 +00:00
|
|
|
const credits = `
|
|
|
|
## Credits
|
|
|
|
${data.credits}
|
|
|
|
`
|
2021-10-11 13:50:24 +00:00
|
|
|
|
|
|
|
const dateString = `${new Date()}`
|
|
|
|
let tzShort =
|
|
|
|
// Works for the majority of modern browsers
|
|
|
|
dateString.match(/\(([^\)]+)\)$/) ||
|
|
|
|
// IE outputs date strings in a different format:
|
|
|
|
dateString.match(/([A-Z]+) [\d]{4}$/)
|
|
|
|
|
|
|
|
if (tzShort) {
|
|
|
|
// Old Firefox uses the long timezone name (e.g., "Central
|
|
|
|
// Daylight Time" instead of "CDT")
|
|
|
|
tzShort = tzShort[1].match(/[A-Z]/g).join('')
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-10-11 17:15:09 +00:00
|
|
|
<InfoLayout title={data.title} subtitle={striptags(data.subtitle)} image={data.image}>
|
2021-10-11 13:50:24 +00:00
|
|
|
{embedURL ? (
|
|
|
|
<VideoEmbed onClose={deactivateEmbed} url={embedURL} />
|
|
|
|
) : null}
|
|
|
|
<Fragment>
|
|
|
|
<InfoContent>
|
2021-10-11 17:15:09 +00:00
|
|
|
<H1>{data.title}:</H1>
|
|
|
|
<H1>{data.subtitle}</H1>
|
|
|
|
<Markdown withLinebreaks>{data.description}</Markdown>
|
2021-10-11 13:50:24 +00:00
|
|
|
|
|
|
|
<Trailer imgSrc={trailerThumb} onClick={onClickTrailerButton} />
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
<a
|
|
|
|
href="https://discord.gg/Xu9D3qVana"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<Button>Join the Discord</Button>
|
|
|
|
</a>
|
|
|
|
<a
|
|
|
|
href="https://ndc.substack.com/subscribe"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<Button>Subscribe to the mailing list</Button>
|
|
|
|
</a>
|
|
|
|
</Row>
|
|
|
|
</InfoContent>
|
|
|
|
{/* {currentVideo && (
|
|
|
|
<Fragment>
|
|
|
|
<Title>{translations.en.nowPlaying}:</Title>
|
2021-10-11 17:15:09 +00:00
|
|
|
<EpisodeCard {...currentVideo} />
|
2021-10-11 13:50:24 +00:00
|
|
|
</Fragment>
|
|
|
|
)}
|
|
|
|
|
2021-10-11 17:15:09 +00:00
|
|
|
*/}
|
|
|
|
{data.episodes.future.length ? (
|
2021-10-11 13:50:24 +00:00
|
|
|
<Fragment>
|
|
|
|
<Title>{translations.en.nextStream}:</Title>
|
2021-10-11 17:15:09 +00:00
|
|
|
{data.episodes.future.map(feeditem => (
|
|
|
|
<EpisodeCard
|
2021-10-11 13:50:24 +00:00
|
|
|
key={feeditem.start}
|
|
|
|
tzShort={tzShort}
|
|
|
|
{...feeditem}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Fragment>
|
|
|
|
) : null}
|
2021-10-11 17:15:09 +00:00
|
|
|
{data.episodes.past.length ? (
|
2021-10-11 13:50:24 +00:00
|
|
|
<Fragment>
|
2021-10-11 17:15:09 +00:00
|
|
|
<Title>Past streams:</Title>
|
|
|
|
{data.episodes.past.map(feeditem => (
|
|
|
|
<EpisodeCard
|
|
|
|
key={feeditem.beginsOn}
|
2021-10-11 13:50:24 +00:00
|
|
|
hasPassed
|
|
|
|
onClickButton={() =>
|
|
|
|
setEmbedUrl(`${config.peertube_root}${feeditem.embedPath}`)
|
|
|
|
}
|
|
|
|
{...feeditem}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</Fragment>
|
2021-10-11 17:15:09 +00:00
|
|
|
) : null}
|
|
|
|
<InfoContent>
|
|
|
|
<Title>Credits</Title>
|
2021-10-11 13:50:24 +00:00
|
|
|
<Markdown>{credits}</Markdown>
|
2021-10-11 17:15:09 +00:00
|
|
|
</InfoContent>
|
2021-10-11 13:50:24 +00:00
|
|
|
</Fragment>
|
|
|
|
|
|
|
|
</InfoLayout>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SeriesPage
|