2022-07-16 15:34:44 +10:00
|
|
|
import "../../components/main.js"
|
|
|
|
|
import getConfig from 'next/config'
|
|
|
|
|
import Layout from "../../components/main.js"
|
|
|
|
|
import { getGallery, getGalleryImages } from "../../data/external/cms.js"
|
|
|
|
|
import GalleryPager from "../../components/gallerypager.js"
|
2022-07-17 12:38:51 +10:00
|
|
|
import Head from 'next/head'
|
2023-06-25 21:40:40 +10:00
|
|
|
import config from "../../data/internal/config.js"
|
2023-12-10 15:22:32 +11:00
|
|
|
import GalleryCarousel from "../../components/gallerycarousel.js"
|
2022-07-16 15:34:44 +10:00
|
|
|
|
|
|
|
|
export async function getServerSideProps(context) {
|
|
|
|
|
|
|
|
|
|
const gallery = await getGallery(context.params.gallery)
|
|
|
|
|
|
|
|
|
|
if(context.query.page == null || context.query.page == '0') {
|
|
|
|
|
var page = 1;
|
|
|
|
|
} else {
|
|
|
|
|
var page = Number(context.query.page)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const galleryImages = await getGalleryImages(context.params.gallery, page, 9)
|
|
|
|
|
|
2023-12-10 18:50:12 +11:00
|
|
|
console.log(galleryImages)
|
|
|
|
|
|
2022-07-16 15:34:44 +10:00
|
|
|
const { serverRuntimeConfig } = getConfig()
|
|
|
|
|
|
|
|
|
|
const pagedata = {
|
2022-07-17 12:38:51 +10:00
|
|
|
'title': "Angry Beanie - " + gallery.data[0].attributes.Title
|
2022-07-16 15:34:44 +10:00
|
|
|
}
|
2023-06-25 21:40:40 +10:00
|
|
|
|
|
|
|
|
const og_image = serverRuntimeConfig.media_path + galleryImages.data[0].attributes.Image.data.attributes.formats.large.url
|
2022-07-16 15:34:44 +10:00
|
|
|
|
|
|
|
|
return {
|
2023-06-25 21:40:40 +10:00
|
|
|
props: {pagedata, gallery: gallery.data[0], galleryImages, serverRuntimeConfig, og_image},
|
2022-07-16 15:34:44 +10:00
|
|
|
}
|
2023-06-25 21:40:40 +10:00
|
|
|
|
2022-07-16 15:34:44 +10:00
|
|
|
}
|
|
|
|
|
|
2023-06-25 21:40:40 +10:00
|
|
|
const Gallery = ({pagedata, gallery, galleryImages, serverRuntimeConfig, og_image}) => {
|
2022-07-16 15:34:44 +10:00
|
|
|
if (!gallery) return null
|
2022-09-08 16:41:46 +10:00
|
|
|
|
2022-07-16 15:34:44 +10:00
|
|
|
return(
|
|
|
|
|
<Layout pagedata={pagedata}>
|
2022-07-17 12:38:51 +10:00
|
|
|
<Head>
|
|
|
|
|
<meta name="twitter:card" content={ gallery.attributes.Title } key="twcard" />
|
|
|
|
|
<meta name="twitter:creator" content="angrybeanie" key="twhandle" />
|
|
|
|
|
<meta name="og:url" content={config.siteURL + "/galleries/" + gallery.attributes.Slug}></meta>
|
|
|
|
|
<meta name="og:type" content="Photo Gallery"></meta>
|
|
|
|
|
<meta name="og:title" content={ gallery.attributes.Title } key="title"></meta>
|
2023-06-25 21:40:40 +10:00
|
|
|
<meta name="og:image" content={og_image}></meta>
|
2022-07-17 12:38:51 +10:00
|
|
|
<meta name="og:description" content={ gallery.attributes.Description } key="description"></meta>
|
|
|
|
|
</Head>
|
2022-07-16 15:34:44 +10:00
|
|
|
<h1 className="page_title col-sm-12">{gallery.attributes.Title}</h1>
|
2023-12-10 15:22:32 +11:00
|
|
|
<GalleryCarousel galleryImages={galleryImages} basepath={serverRuntimeConfig.media_path} gallery={gallery}></GalleryCarousel>
|
|
|
|
|
<GalleryPager galleryImages={galleryImages} basepath={serverRuntimeConfig.media_path} gallery={gallery}></GalleryPager>
|
2022-07-16 15:34:44 +10:00
|
|
|
</Layout>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Gallery
|