diff --git a/components/gallerypager.js b/components/gallerypager.js
index ba025b2..3f93f26 100755
--- a/components/gallerypager.js
+++ b/components/gallerypager.js
@@ -1,12 +1,16 @@
import ReactPaginate from "react-paginate";
import { useRouter } from "next/router";
import Image from 'next/image';
-import getConfig from 'next/config'
+import Link from 'next/link'
-const GalleryPager = ({gallery, basepath}) => {
+const GalleryPager = ({galleryImages, basepath, gallery}) => {
const router = useRouter()
+ const handleImageClick = (e, path) => {
+ alert(path)
+ }
+
const handlePagination = page => {
const path = router.pathname
const query = router.query
@@ -17,33 +21,77 @@ const GalleryPager = ({gallery, basepath}) => {
})
}
+ const carouselList = []
+ for (var i = 0; i < galleryImages.meta.pagination.total; i++) {
+ carouselList.push(
)
+ }
+
return (
- {gallery.data.map((galleryImage) => {
- var imageUrl = basepath + galleryImage.attributes.Image.data.attributes.formats.small.url
- return (
-
-
-
- )})}
-
-
+ {galleryImages.data.map((galleryImage) => {
+ var imageUrl = basepath + galleryImage.attributes.Image.data.attributes.formats.small.url
+ var imageLink = "/galleryimages/" + galleryImage.attributes.Slug
+ return (
+
+
+
+ )})}
+
+
+
)
diff --git a/data/external/cms.js b/data/external/cms.js
index 8a8ca4a..ec44e51 100755
--- a/data/external/cms.js
+++ b/data/external/cms.js
@@ -292,6 +292,43 @@ export const getGallery = async (gallerySlug) => {
return await galres.json()
}
+export const getAllGalleryImages = async () => {
+ const { serverRuntimeConfig } = getConfig()
+ const qs = require('qs')
+
+ const imageres = await fetch(process.env.API + `gallery-images`, {
+ headers: new Headers({
+ 'Authorization': serverRuntimeConfig.strapi_token,
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ })
+ })
+
+ return imageres.json()
+}
+
+export const getGalleryImage = async (imageSlug) => {
+ const { serverRuntimeConfig } = getConfig()
+ const qs = require('qs')
+console.log("Imageslug: " +imageSlug)
+ var query = qs.stringify({
+ filters: {
+ Slug: {
+ $eq: imageSlug
+ }
+ },
+ populate: '*'
+ })
+
+ const imageres = await fetch(process.env.API + `gallery-images?${query}`, {
+ headers: new Headers({
+ 'Authorization': serverRuntimeConfig.strapi_token,
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ })
+ })
+
+ return await imageres.json()
+}
+
export const getGalleryImages = async (galleryId, page, limit) => {
const { serverRuntimeConfig } = getConfig()
const qs = require('qs')
@@ -324,7 +361,7 @@ export const getGalleryImages = async (galleryId, page, limit) => {
})
})
- return galres.json()
+ return await galres.json()
}
export const getPodcastList = async (podcastStatus) => {
diff --git a/pages/galleries/[gallery].js b/pages/galleries/[gallery].js
index a0956a5..cc125c2 100755
--- a/pages/galleries/[gallery].js
+++ b/pages/galleries/[gallery].js
@@ -43,7 +43,7 @@ console.log(gallery)
{gallery.attributes.Title}
-
+
)
}
diff --git a/pages/galleryimages/[galleryImage].js b/pages/galleryimages/[galleryImage].js
new file mode 100755
index 0000000..945e02a
--- /dev/null
+++ b/pages/galleryimages/[galleryImage].js
@@ -0,0 +1,58 @@
+import Head from "next/head";
+import Image from "next/image";
+import getConfig from 'next/config'
+import "../../components/main.js"
+import Layout from "../../components/main.js"
+import { getAllGalleryImages, getGalleryImage } from "../../data/external/cms.js";
+
+const galleryImage = ({pagedata, imageDetails, basepath} ) => {
+ if(!imageDetails) return null
+
+ return (
+
+
+
+
+ )
+}
+
+export default galleryImage
+
+export async function getStaticPaths() {
+ const posts = await getAllGalleryImages()
+ const paths = posts.data.map((post) => ({
+ params: { galleryImage: post.attributes.Slug },
+ }))
+ return {
+ paths,
+ fallback: true // false or 'blocking'
+ };
+}
+
+export async function getStaticProps (context){
+
+ const { serverRuntimeConfig } = getConfig()
+
+ const slug = context.params.galleryImage
+
+ const galImage = await getGalleryImage(slug)
+
+ console.log(galImage.data[0].attributes.Title)
+
+ const pagedata = {
+ 'title': "Angry Beanie - " + galImage.data[0].attributes.Title
+ }
+
+ return {
+ props: { pagedata, imageDetails: galImage, basepath: serverRuntimeConfig.media_path }
+ }
+}
+