29 lines
No EOL
978 B
JavaScript
Executable file
29 lines
No EOL
978 B
JavaScript
Executable file
import Layout from "../../components/main"
|
|
import Link from 'next/link'
|
|
import getConfig from 'next/config'
|
|
|
|
export async function getServerSideProps(context) {
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
|
const pslug = context.params.page
|
|
const res = await fetch(serverRuntimeConfig.base_path + `/api/page/` + pslug)
|
|
const pagedata = await res.json()
|
|
|
|
pagedata.title = "Angry Beanie - " + pagedata.title
|
|
|
|
const secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`)
|
|
const secdata = await secres.json()
|
|
|
|
return {
|
|
props: { sections : secdata, pagedata }, // will be passed to the page component as props
|
|
}
|
|
}
|
|
|
|
function Page ({articles, sections, pagedata}) {
|
|
return (<Layout sections={sections} pagedata={pagedata}>
|
|
<h1>{pagedata.title}</h1>
|
|
<div class="page_body" dangerouslySetInnerHTML={{ __html: pagedata.body }}>
|
|
</div>
|
|
</Layout>);
|
|
}
|
|
|
|
export default Page |