2020-12-06 21:49:37 +11:00
|
|
|
import "../components/main"
|
2021-02-04 14:27:14 +11:00
|
|
|
import getConfig from 'next/config'
|
2020-12-06 21:49:37 +11:00
|
|
|
import Layout from "../components/main"
|
2021-02-04 14:27:14 +11:00
|
|
|
import StoryPager from "../components/storypager"
|
2020-12-06 21:49:37 +11:00
|
|
|
import Link from 'next/link'
|
2021-02-04 14:27:14 +11:00
|
|
|
import StorySideBar from "../components/storysidebar"
|
2020-12-06 21:49:37 +11:00
|
|
|
|
|
|
|
|
export async function getServerSideProps(context) {
|
2021-02-04 14:27:14 +11:00
|
|
|
if(context.query.page == null || context.query.page == '0') {
|
|
|
|
|
var page = 0;
|
|
|
|
|
} else {
|
|
|
|
|
var page = Number(context.query.page) - 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
|
|
|
|
|
|
|
|
|
const res = await fetch(serverRuntimeConfig.base_path + `/api/documents/`+ page + `/5`)
|
2020-12-06 21:49:37 +11:00
|
|
|
const articles = await res.json()
|
|
|
|
|
|
2021-02-04 14:27:14 +11:00
|
|
|
const secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`)
|
2020-12-06 21:49:37 +11:00
|
|
|
const secdata = await secres.json()
|
2021-02-04 14:27:14 +11:00
|
|
|
|
|
|
|
|
const pagedata = {'title': 'Angry Beanie News'}
|
2020-12-06 21:49:37 +11:00
|
|
|
|
|
|
|
|
return {
|
2021-02-04 14:27:14 +11:00
|
|
|
props: { articles, sections : secdata, pagedata }, // will be passed to the page component as props
|
2020-12-06 21:49:37 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-04 14:27:14 +11:00
|
|
|
function News({ articles, sections, pagedata }) {
|
|
|
|
|
return <Layout sections={sections} pagedata={pagedata}>
|
2020-12-06 21:49:37 +11:00
|
|
|
<h1>NEWS</h1>
|
2021-02-04 14:27:14 +11:00
|
|
|
<StoryPager storydata={articles} />
|
2020-12-06 21:49:37 +11:00
|
|
|
</Layout>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default News
|