Finished integrating basic Gallery image page
This commit is contained in:
parent
027915e981
commit
89a8069f1a
4 changed files with 38 additions and 13 deletions
25
data/external/cms.js
vendored
25
data/external/cms.js
vendored
|
|
@ -306,10 +306,31 @@ export const getAllGalleryImages = async () => {
|
|||
return imageres.json()
|
||||
}
|
||||
|
||||
export const getLatestGalleryImage = async () => {
|
||||
const { serverRuntimeConfig } = getConfig()
|
||||
const qs = require('qs')
|
||||
var query = qs.stringify({
|
||||
pagination: {
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
},
|
||||
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 imageres.json()
|
||||
}
|
||||
|
||||
export const getGalleryImage = async (imageSlug) => {
|
||||
const { serverRuntimeConfig } = getConfig()
|
||||
const qs = require('qs')
|
||||
console.log("Imageslug: " +imageSlug)
|
||||
|
||||
var query = qs.stringify({
|
||||
filters: {
|
||||
Slug: {
|
||||
|
|
@ -337,8 +358,6 @@ export const getGalleryImages = async (galleryId, page, limit) => {
|
|||
page = 0
|
||||
}
|
||||
|
||||
console.log(page)
|
||||
|
||||
var query = qs.stringify({
|
||||
filters: {
|
||||
galleries: {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export async function getServerSideProps(context) {
|
|||
|
||||
const Gallery = ({pagedata, gallery, galleryImages, serverRuntimeConfig}) => {
|
||||
if (!gallery) return null
|
||||
console.log(gallery)
|
||||
|
||||
return(
|
||||
<Layout pagedata={pagedata}>
|
||||
<Head>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ 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
|
||||
|
||||
|
|
@ -19,7 +20,14 @@ const galleryImage = ({pagedata, imageDetails, basepath} ) => {
|
|||
width={imageDetails.data[0].attributes.Image.data.attributes.formats.large.width}
|
||||
height={imageDetails.data[0].attributes.Image.data.attributes.formats.large.height}
|
||||
></Image>
|
||||
<div className="col-sm-9"><h2>Photo Information</h2></div>
|
||||
<div className="col-sm-9 article_body">
|
||||
<h2>Photo Information</h2>
|
||||
<div>
|
||||
<p><strong>Title:</strong> {imageDetails.data[0].attributes.Title}</p>
|
||||
<p><strong>Gallery:</strong> <a href={"/galleries/" + imageDetails.data[0].attributes.galleries.data[0].attributes.Slug}>{imageDetails.data[0].attributes.galleries.data[0].attributes.Title}</a></p>
|
||||
<p dangerouslySetInnerHTML={{ __html: imageDetails.data[0].attributes.galleries.data[0].attributes.Description}}></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Layout>)
|
||||
}
|
||||
|
|
@ -45,14 +53,13 @@ export async function getStaticProps (context){
|
|||
|
||||
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 }
|
||||
props: { pagedata, imageDetails: galImage, basepath: serverRuntimeConfig.media_path },
|
||||
revalidate: 60
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { FEEDS, getFeed } from "../lib/rss"
|
|||
import { generatePodcastFeeds, generateRssFeed } from "../data/internal/feed-generator"
|
||||
import { generateSitemap } from "../data/internal/sitemap-generator"
|
||||
import { getLatestPodcastEpisode } from "../data/external/cms"
|
||||
import { getLatestGalleryImage } from "../data/external/cms"
|
||||
|
||||
export async function getStaticProps(context) {
|
||||
generateRssFeed()
|
||||
|
|
@ -42,9 +43,7 @@ export async function getStaticProps(context) {
|
|||
|
||||
const epdata = await getLatestPodcastEpisode()
|
||||
|
||||
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 firstimage = await getLatestGalleryImage()
|
||||
|
||||
const pagedata = {'title': 'Angry Beanie'}
|
||||
|
||||
|
|
@ -118,8 +117,8 @@ function HomePage (props) {
|
|||
<div className="col-sm-4">
|
||||
<div className="card">
|
||||
<div className="card-img-top">
|
||||
<a href={props.firstimage.link} target="_blank">
|
||||
<img className="featuredFlickr" src={ props.firstimage.media.m }></img>
|
||||
<a href={"/galleryimages/" + props.firstimage.data[0].attributes.Slug}>
|
||||
<img className="featuredFlickr" src={ props.config.media_path + props.firstimage.data[0].attributes.Image.data.attributes.formats.thumbnail.url }></img>
|
||||
</a>
|
||||
</div>
|
||||
<div className="card-title">
|
||||
|
|
|
|||
Loading…
Reference in a new issue