49 lines
No EOL
2.3 KiB
JavaScript
Executable file
49 lines
No EOL
2.3 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"
|
|
|
|
export async function getServerSideProps(context) {
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
|
const slug = context.params.podcast
|
|
const url = serverRuntimeConfig.base_path + '/api/podcast-serie?filters[Slug][$eq]=' + slug
|
|
const showres = await fetch(url, {
|
|
headers: new Headers({
|
|
'Authorization': 'Bearer 77df3f9be0a33ee3e91e4314e99fe649348fe15e66348fa53cc335e936345661bea7eb3c826475bc8605037d9753e334061f579aa864a5c5a7436dc3b6853ee4712c822b462156d445cebe08b3e298967829ceccb4c4aa7c61c674527ddf66514a9879b36b15732fc4f505945fbe9e23e65c0525fce834b3858936ab2ab671b7',
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
})
|
|
})
|
|
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 + "podcast-episodes?filters[podcast_sery][slug][$eq]="+slug+"&populate=*", {
|
|
headers: new Headers({
|
|
'Authorization': 'Bearer 77df3f9be0a33ee3e91e4314e99fe649348fe15e66348fa53cc335e936345661bea7eb3c826475bc8605037d9753e334061f579aa864a5c5a7436dc3b6853ee4712c822b462156d445cebe08b3e298967829ceccb4c4aa7c61c674527ddf66514a9879b36b15732fc4f505945fbe9e23e65c0525fce834b3858936ab2ab671b7',
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
})
|
|
})
|
|
const epdata = await epres.json()
|
|
console.log(epdata.data)
|
|
|
|
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.data} config={props.serverRuntimeConfig} showdata={props.showdata}/>
|
|
</Layout>
|
|
)
|
|
|
|
export default Podcast |