2021-02-04 14:27:14 +11:00
|
|
|
import getConfig from 'next/config'
|
2020-12-06 21:49:37 +11:00
|
|
|
import "../../components/main.js"
|
|
|
|
|
import Layout from "../../components/main.js"
|
2021-02-04 14:27:14 +11:00
|
|
|
import FeatureImage from "../../components/featureimage.js"
|
|
|
|
|
import StorySideBar from '../../components/storysidebar.js'
|
2021-09-05 16:12:45 +10:00
|
|
|
import * as gtag from "../../lib/gtag"
|
|
|
|
|
import Image from 'next/image';
|
2020-12-06 21:49:37 +11:00
|
|
|
|
|
|
|
|
export async function getServerSideProps(context) {
|
2021-02-04 14:27:14 +11:00
|
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
2020-12-06 21:49:37 +11:00
|
|
|
const slug = context.params.slug
|
2021-02-04 14:27:14 +11:00
|
|
|
const url = serverRuntimeConfig.base_path + '/api/document/' + slug
|
|
|
|
|
|
2020-12-06 21:49:37 +11:00
|
|
|
const res = await fetch(url)
|
|
|
|
|
const article_obj = await res.json()
|
|
|
|
|
|
2021-02-04 14:27:14 +11:00
|
|
|
const stories = await fetch(serverRuntimeConfig.base_path + `/api/documents/0/5`)
|
|
|
|
|
const storydata = await stories.json()
|
|
|
|
|
|
|
|
|
|
const pagedata = {
|
|
|
|
|
'title': "Angry Beanie - " + article_obj.title
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const secres = await fetch(serverRuntimeConfig.base_path + '/api/sections')
|
2020-12-06 21:49:37 +11:00
|
|
|
const secdata = await secres.json()
|
|
|
|
|
|
|
|
|
|
return {
|
2021-09-05 16:12:45 +10:00
|
|
|
props: { article_obj, sections: secdata, pagedata, storydata, serverRuntimeConfig}, // will be passed to the page component as props
|
2020-12-06 21:49:37 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-05 16:12:45 +10:00
|
|
|
const Article = ({article_obj, sections, pagedata, storydata, serverRuntimeConfig}) => (
|
2021-02-04 14:27:14 +11:00
|
|
|
<Layout sections={sections} pagedata={pagedata}>
|
|
|
|
|
<div className="main_content col-md-9 col-sm-12">
|
2021-09-05 16:12:45 +10:00
|
|
|
<FeatureImage imagedata = {article_obj.image} basepath = {serverRuntimeConfig.base_path} ></FeatureImage>
|
2021-02-04 14:27:14 +11:00
|
|
|
<h1>{article_obj.title}</h1>
|
|
|
|
|
<div className="article_body" dangerouslySetInnerHTML={{ __html: article_obj.body }}></div>
|
|
|
|
|
</div>
|
|
|
|
|
<StorySideBar stories={storydata} />
|
2020-12-06 21:49:37 +11:00
|
|
|
</Layout>
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
export default Article
|