2020-12-06 21:49:37 +11:00
|
|
|
import Layout from "../components/main"
|
2023-05-13 14:17:09 +10:00
|
|
|
import FeatureImage from "../components/featureimage"
|
|
|
|
|
import PublishedInfo from '../components/publishedinfo.js'
|
2021-02-04 14:27:14 +11:00
|
|
|
import getConfig from 'next/config'
|
2021-09-29 21:25:05 +10:00
|
|
|
import Head from 'next/head'
|
2023-05-21 16:08:37 +10:00
|
|
|
import config from '../data/internal/config'
|
2022-06-12 15:12:28 +10:00
|
|
|
import { generatePodcastFeeds, generateRssFeed } from "../data/internal/feed-generator"
|
2022-06-17 21:57:06 +10:00
|
|
|
import { generateSitemap } from "../data/internal/sitemap-generator"
|
2023-05-13 14:17:09 +10:00
|
|
|
import { getLatestContent, getLatestPodcastEpisode } from "../data/external/cms"
|
2022-09-08 16:41:46 +10:00
|
|
|
import { getLatestGalleryImage } from "../data/external/cms"
|
2020-12-06 21:49:37 +11:00
|
|
|
|
2022-06-12 15:12:28 +10:00
|
|
|
export async function getStaticProps(context) {
|
|
|
|
|
generateRssFeed()
|
|
|
|
|
generateRssFeed('tech-and-disability')
|
|
|
|
|
generatePodcastFeeds()
|
2022-06-17 21:57:06 +10:00
|
|
|
generateSitemap()
|
2022-07-16 15:34:44 +10:00
|
|
|
const { serverRuntimeConfig } = getConfig()
|
2022-06-12 15:12:28 +10:00
|
|
|
|
|
|
|
|
const qs = require('qs')
|
|
|
|
|
const query = qs.stringify({
|
|
|
|
|
pagination: {
|
|
|
|
|
limit: 1
|
|
|
|
|
},
|
2022-06-27 11:31:19 +10:00
|
|
|
populate: {
|
|
|
|
|
FeatureImage: '*'
|
|
|
|
|
},
|
2022-06-12 15:12:28 +10:00
|
|
|
sort: ['publishedAt:desc'],
|
|
|
|
|
}, {
|
|
|
|
|
encodeValuesOnly: true,
|
|
|
|
|
})
|
2022-06-26 14:59:45 +10:00
|
|
|
|
2022-06-12 15:12:28 +10:00
|
|
|
const res = await fetch(serverRuntimeConfig.base_path +`articles?${query}`, {
|
|
|
|
|
headers: new Headers({
|
|
|
|
|
'Authorization': serverRuntimeConfig.strapi_token,
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
|
|
|
})
|
|
|
|
|
})
|
2020-12-06 21:49:37 +11:00
|
|
|
const artdata = await res.json()
|
|
|
|
|
|
2022-06-12 15:12:28 +10:00
|
|
|
const article = artdata.data[0].attributes
|
|
|
|
|
|
2021-02-04 14:27:14 +11:00
|
|
|
const pagedata = {'title': 'Angry Beanie'}
|
2023-05-13 14:17:09 +10:00
|
|
|
|
|
|
|
|
const combined = getLatestContent()
|
|
|
|
|
|
2020-12-06 21:49:37 +11:00
|
|
|
return {
|
2024-10-07 15:56:54 +11:00
|
|
|
props: { article, pagedata, config: serverRuntimeConfig, siteConfig: config},
|
2022-06-13 13:13:11 +10:00
|
|
|
revalidate: 60 // 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 HomePage (props) {
|
2023-05-13 14:17:09 +10:00
|
|
|
var featureImage
|
|
|
|
|
|
|
|
|
|
if (props.article.FeatureImage.data) {
|
|
|
|
|
if (props.article.FeatureImage.data.attributes.formats.large) {
|
|
|
|
|
featureImage = props.article.FeatureImage.data.attributes.formats.large
|
|
|
|
|
featureImage.name = props.article.FeatureImage.data.attributes.alternativeText
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var article_desc = props.article.Abstract.replace(new RegExp('<[^>]*>', 'g'), '')
|
|
|
|
|
|
|
|
|
|
return <Layout pagedata={props.pagedata}>
|
|
|
|
|
<Head>
|
|
|
|
|
<meta name="twitter:card" content={ article_desc } key="twcard" />
|
|
|
|
|
<meta name="twitter:creator" content="angrybeanie" key="twhandle" />
|
|
|
|
|
<meta name="og:url" content={config.siteURL + "/news/" + props.article.Slug}></meta>
|
|
|
|
|
<meta name="og:type" content="article"></meta>
|
|
|
|
|
<meta name="og:title" content={ props.article.Title } key="title"></meta>
|
|
|
|
|
<meta name="og:description" content={ article_desc } key="description"></meta>
|
|
|
|
|
{ props.article.FeatureImage.data != null &&
|
|
|
|
|
<meta name="og:image" content={props.config.media_path + featureImage.url}></meta>
|
|
|
|
|
}
|
2021-09-29 21:25:05 +10:00
|
|
|
</Head>
|
2023-05-13 14:17:09 +10:00
|
|
|
<div className="main_content col-md-9 col-sm-12">
|
|
|
|
|
{ props.article.FeatureImage.data != null &&
|
|
|
|
|
<FeatureImage imagedata = {featureImage} basepath = {props.config.media_path} ></FeatureImage>
|
|
|
|
|
}
|
|
|
|
|
<h1 className="page_title col-sm-12">{ props.article.Title }</h1>
|
|
|
|
|
<PublishedInfo publishData={props.article}></PublishedInfo>
|
2023-09-10 13:38:30 +10:00
|
|
|
<div className="article_body" dangerouslySetInnerHTML={{ __html: props.article.FullBody }}></div>
|
2021-09-05 16:12:45 +10:00
|
|
|
</div>
|
2023-05-13 14:17:09 +10:00
|
|
|
</Layout>
|
2020-12-06 21:49:37 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default HomePage
|