38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
|
|
import getConfig from 'next/config'
|
||
|
|
import "../../../components/main.js"
|
||
|
|
import Layout from "../../../components/main.js"
|
||
|
|
import EpisodePager from "../../../components/episodepager.js"
|
||
|
|
|
||
|
|
export async function getServerSideProps(context) {
|
||
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
||
|
|
const slug = context.params.podcast
|
||
|
|
const url = serverRuntimeConfig.base_path + '/api/podcasts/series/' + slug
|
||
|
|
const showres = await fetch(url)
|
||
|
|
const showdata = await showres.json()
|
||
|
|
|
||
|
|
if(context.query.page == null || context.query.page == '0') {
|
||
|
|
var page = 0;
|
||
|
|
} else {
|
||
|
|
var page = Number(context.query.page) - 1
|
||
|
|
}
|
||
|
|
const epres = await fetch(serverRuntimeConfig.base_path + "/api/podcasts/episodes/"+slug+"/"+page+"/10")
|
||
|
|
const epdata = await epres.json()
|
||
|
|
|
||
|
|
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}/>
|
||
|
|
</Layout>
|
||
|
|
)
|
||
|
|
|
||
|
|
export default Podcast
|