stream/src/pages/SeriesPage/index.js

112 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-10-11 13:50:24 +00:00
/* eslint-disable react/prop-types */
import { h, Fragment } from 'preact'
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-12 12:45:52 +00:00
import InfoLayout from '../../layouts/InfoLayout'
2021-10-11 13:50:24 +00:00
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,
Row,
ActionButton as Button,
2021-10-12 12:45:52 +00:00
TrailerContainer,
2021-10-11 13:50:24 +00:00
} from './styles'
import config from '../../data/config'
2021-10-12 12:45:52 +00:00
import Page from '../../layouts/Page'
2021-10-11 13:50:24 +00:00
const SeriesPage = ({ data }) => {
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-12 12:45:52 +00:00
<Page title={data.title}>
<InfoLayout title={data.title} subtitle={data.subtitle} image={data.image} theme={data.theme}>
<Fragment>
<InfoContent>
<H1>{data.title}:</H1>
<H1>{data.subtitle}</H1>
<Markdown withLinebreaks>{data.description}</Markdown>
2021-10-11 13:50:24 +00:00
2021-10-12 12:45:52 +00:00
{data.trailer ? (
<TrailerContainer>
<VideoEmbed url={data.trailer} />
</TrailerContainer>
) : null}
2021-10-11 13:50:24 +00:00
2021-10-12 12:45:52 +00:00
{data.links.length ?
<Row wrap>
{data.links.map(link => (
<a
href={link.resourceUrl}
target="_blank"
rel="noopener noreferrer"
>
<Button>{link.summary}</Button>
</a>
))}
</Row> : null
}
</InfoContent>
{data.episodes.future.length ? (
<Fragment>
<Title>{translations.en.nextStream}:</Title>
{data.episodes.future.map(feeditem => (
<EpisodeCard
theme={data.theme}
key={feeditem.start}
tzShort={tzShort}
{...feeditem}
/>
))}
</Fragment>
) : null}
{data.episodes.past.length ? (
<Fragment>
<Title>Past streams:</Title>
{data.episodes.past.map(feeditem => (
<EpisodeCard
theme={data.theme}
key={feeditem.beginsOn}
hasPassed
onClickButton={() =>
setEmbedUrl(`${config.peertube_root}${feeditem.embedPath}`)
}
{...feeditem}
/>
))}
</Fragment>
) : null}
<InfoContent>
<Title>Credits</Title>
<Markdown>{credits}</Markdown>
</InfoContent>
</Fragment>
2021-10-11 13:50:24 +00:00
2021-10-12 12:45:52 +00:00
</InfoLayout>
</Page>
2021-10-11 13:50:24 +00:00
)
}
export default SeriesPage