73 lines
No EOL
2.8 KiB
JavaScript
Executable file
73 lines
No EOL
2.8 KiB
JavaScript
Executable file
import Layout from "../components/main"
|
|
import LatestEpisodes from "../components/latestepisodes"
|
|
import Link from 'next/link'
|
|
import getConfig from 'next/config'
|
|
import Head from 'next/head'
|
|
import Image from 'next/image';
|
|
import { FEEDS, getFeed } from "../lib/rss"
|
|
|
|
export async function getServerSideProps(context) {
|
|
const { serverRuntimeConfig, publicRuntimeConfig } = getConfig()
|
|
const res = await fetch(serverRuntimeConfig.base_path +`/api/collections/1`)
|
|
const artdata = await res.json()
|
|
const article = artdata.articles[0]
|
|
|
|
const epres = await fetch(serverRuntimeConfig.base_path + '/api/podcasts/episodes/latest/0/1')
|
|
const epdata = await epres.json()
|
|
|
|
const flickr = await fetch('https://www.flickr.com/services/feeds/photos_public.gne?id=25875680@N05&lang=en-us&format=json&nojsoncallback=1')
|
|
const flickrdata = await flickr.json()
|
|
const firstimage = flickrdata.items[0]
|
|
|
|
const pagedata = {'title': 'Angry Beanie'}
|
|
|
|
const tadfeed = FEEDS.find((tadfeed) => tadfeed.name === "tad");
|
|
const tadfullfeed = await getFeed(tadfeed.url)
|
|
const tadfirstitem = tadfullfeed.items[0]
|
|
|
|
return {
|
|
props: { article, pagedata, episodedata: epdata.episodes, config: serverRuntimeConfig, tadfirstitem, firstimage}, // will be passed to the page component as props
|
|
}
|
|
}
|
|
|
|
function HomePage (props) {
|
|
return (
|
|
<div>
|
|
<Head>
|
|
<title>{props.pagedata.title}</title>
|
|
</Head>
|
|
<div className="container">
|
|
<div className="frontPageImage">
|
|
<img className="header_image img-fluid" src="/images/logo.png" alt="Angry Beanie" />
|
|
</div>
|
|
<div className="card col-sm-3">
|
|
<h3>Latest Blog Post</h3>
|
|
<Link href="/news/[slug]" as={"/news/" + props.article.slug}>{props.article.title}</Link>
|
|
{props.article.abstract}
|
|
</div>
|
|
{props.episodedata.map((episode) => (
|
|
<div className="card col-sm-3">
|
|
<h3>Latest Podcast</h3>
|
|
<Link href={episode.show_slug + "/" + episode.episode_slug}>{episode.title}</Link>
|
|
<Image
|
|
src={props.config.base_path + "/" + episode.logo.src}
|
|
height={episode.logo.height}
|
|
width="100%"
|
|
></Image>
|
|
<div dangerouslySetInnerHTML={{ __html: episode.episode_lead}}></div>
|
|
</div>
|
|
))}
|
|
<div className="card col-sm-3">
|
|
<h3>Latest Tech And Disability Post</h3>
|
|
<a href={props.tadfirstitem.link} target="_blank">{props.tadfirstitem.title}</a>
|
|
</div>
|
|
<div className="card col-sm-3">
|
|
<h3>Latest Photo</h3>
|
|
<img src={ props.firstimage.media.m } height="100" width="100"></img>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default HomePage |