angrybeanie-front-end/pages/tech-and-disability.js

46 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

import "../components/main"
import getConfig from 'next/config'
2022-06-18 21:36:21 +10:00
import config from "../data/internal/config"
import Layout from "../components/main"
import StoryPager from "../components/storypager"
import { getAllPosts, getProjectDetails } from "../data/external/cms";
2022-06-18 21:36:21 +10:00
import Head from 'next/head'
//import { popStoryPager } from "../data/external/cms"
export async function getServerSideProps(context) {
if(context.query.page == null || context.query.page == '0') {
var page = 1;
} else {
var page = Number(context.query.page)
}
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
const project = await getProjectDetails('tech-and-disability')
2022-06-18 21:36:21 +10:00
const rssFeed = config.siteURL+"/feed/"+project.data[0].attributes.Slug+"-feed.xml"
const articles = await getAllPosts(project.data[0].attributes.Slug, page, 5)
const secres = await fetch(serverRuntimeConfig.base_path + `/api/sections`)
const secdata = await secres.json()
const pagedata = {'title': 'Tech and Disability'}
return {
2022-06-18 21:36:21 +10:00
props: { articles, sections : secdata, pagedata, project, rssFeed}, // will be passed to the page component as props
}
}
2022-06-18 21:36:21 +10:00
function Project({ articles, sections, pagedata, project, rssFeed }) {
return <div><Head>
<link rel="alternate" type="application/rss+xml" title="Tech and Disability Feed" href={rssFeed} />
2022-06-18 21:36:21 +10:00
</Head>
<Layout sections={sections} pagedata={pagedata}>
<h1 className="page_title col-sm-12">{project.data[0].attributes.Title}</h1>
<div dangerouslySetInnerHTML={{ __html: project.data[0].attributes.Description }}></div>
<StoryPager storydata={articles} />
2022-06-18 21:36:21 +10:00
</Layout></div>
}
export default Project