41 lines
No EOL
1.5 KiB
JavaScript
Executable file
41 lines
No EOL
1.5 KiB
JavaScript
Executable file
import getConfig from 'next/config'
|
|
import "../../../components/main.js"
|
|
import Layout from "../../../components/main.js"
|
|
import EpisodePager from "../../../components/episodepager.js"
|
|
import { getPodcastSeries, getPodcastSeriesEpisodes } from '../../../data/external/cms.js'
|
|
import ShowSideBar from '../../../components/showsidebar.js'
|
|
|
|
export async function getServerSideProps(context) {
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
|
const slug = context.params.podcast
|
|
const showdata = await getPodcastSeries(slug)
|
|
|
|
console.log(showdata.data)
|
|
|
|
if(context.query.page == null || context.query.page == '0') {
|
|
var page = 0;
|
|
} else {
|
|
var page = Number(context.query.page)
|
|
}
|
|
|
|
const epdata = await getPodcastSeriesEpisodes(slug, 5, page)
|
|
|
|
const secres = await fetch(serverRuntimeConfig.base_path + '/api/sections')
|
|
const secdata = await secres.json()
|
|
|
|
const pagedata = {
|
|
'title': 'Angry Beanie - ' + showdata.title
|
|
}
|
|
return {
|
|
props: {pagedata, sections: secdata, showdata, epdata, serverRuntimeConfig}
|
|
}
|
|
}
|
|
const Podcast = (props) => (
|
|
<Layout pagedata={props.pagedata} sections={props.sections} showdata={props.showdata}>
|
|
<h1>{props.showdata.title}</h1>
|
|
<EpisodePager episodedata={props.epdata} config={props.serverRuntimeConfig} showdata={props.showdata}/>
|
|
<ShowSideBar props={props.showdata}></ShowSideBar>
|
|
</Layout>
|
|
)
|
|
|
|
export default Podcast |