2020-12-06 21:49:37 +11:00
import Layout from "../components/main"
2021-02-04 14:27:14 +11:00
import LatestEpisodes from "../components/latestepisodes"
2020-12-06 21:49:37 +11:00
import Link from 'next/link'
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'
import Image from 'next/image' ;
import { FEEDS , getFeed } from "../lib/rss"
2020-12-06 21:49:37 +11:00
2021-02-04 14:27:14 +11:00
export async function getServerSideProps ( context ) {
const { serverRuntimeConfig , publicRuntimeConfig } = getConfig ( )
const res = await fetch ( serverRuntimeConfig . base _path + ` /api/collections/1 ` )
2020-12-06 21:49:37 +11:00
const artdata = await res . json ( )
2021-09-29 21:25:05 +10:00
const article = artdata . articles [ 0 ]
2020-12-06 21:49:37 +11:00
2021-09-29 21:25:05 +10:00
const epres = await fetch ( serverRuntimeConfig . base _path + '/api/podcasts/episodes/latest/0/1' )
2021-02-04 14:27:14 +11:00
const epdata = await epres . json ( )
2021-09-29 21:25:05 +10:00
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 ]
2021-02-04 14:27:14 +11:00
const pagedata = { 'title' : 'Angry Beanie' }
2021-09-29 21:25:05 +10:00
const tadfeed = FEEDS . find ( ( tadfeed ) => tadfeed . name === "tad" ) ;
const tadfullfeed = await getFeed ( tadfeed . url )
const tadfirstitem = tadfullfeed . items [ 0 ]
2020-12-06 21:49:37 +11:00
return {
2021-09-29 21:25:05 +10:00
props : { article , pagedata , episodedata : epdata . episodes , config : serverRuntimeConfig , tadfirstitem , firstimage } , // 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 ) {
2021-09-29 21:25:05 +10:00
return (
< div >
< Head >
< title > { props . pagedata . title } < / t i t l e >
< / H e a d >
< div className = "container" >
< div className = "frontPageImage" >
< img className = "header_image img-fluid" src = "/images/logo.png" alt = "Angry Beanie" / >
< / d i v >
< div className = "card col-sm-3" >
< h3 > Latest Blog Post < / h 3 >
< Link href = "/news/[slug]" as = { "/news/" + props . article . slug } > { props . article . title } < / L i n k >
{ props . article . abstract }
< / d i v >
{ props . episodedata . map ( ( episode ) => (
< div className = "card col-sm-3" >
< h3 > Latest Podcast < / h 3 >
< Link href = { episode . show _slug + "/" + episode . episode _slug } > { episode . title } < / L i n k >
< Image
src = { props . config . base _path + "/" + episode . logo . src }
height = { episode . logo . height }
width = "100%"
> < / I m a g e >
< div dangerouslySetInnerHTML = { { _ _html : episode . episode _lead } } > < / d i v >
< / d i v >
) ) }
< div className = "card col-sm-3" >
< h3 > Latest Tech And Disability Post < / h 3 >
2021-09-30 21:10:11 +10:00
< a href = { props . tadfirstitem . link } target = "_blank" > { props . tadfirstitem . title } < / a >
2021-09-29 21:25:05 +10:00
< / d i v >
< div className = "card col-sm-3" >
< h3 > Latest Photo < / h 3 >
< img src = { props . firstimage . media . m } height = "100" width = "100" > < / i m g >
< / d i v >
2021-09-05 16:12:45 +10:00
< / d i v >
2021-09-29 21:25:05 +10:00
< / d i v >
) ;
2020-12-06 21:49:37 +11:00
}
export default HomePage