Closed kgnfth closed 3 years ago
i made it work now this is the working code
<template>
<div class="container pt-12 mx-auto max-w-7xl">
<div class="flex items-end justify-between mb-12 header">
<p class="mb-4 text-4xl font-bold text-gray-800">{{ album.title }}</p>
</div>
<CoolLightBox
:items="images"
:index="imageIndex"
@close="imageIndex = null"
>
</CoolLightBox>
<div v-for="photo in album.photos" :key="photo.id">
<vue-justified-layout
v-slot="{ item, index }"
:items="photo.image"
:options="justifiedOptions"
>
<img
:key="index"
class="cursor-pointer hover:opacity-75"
:src="getStrapiMedia(item.url)"
@click="imageIndex = index"
/>
</vue-justified-layout>
</div>
</div>
</template>
<script>
import { getStrapiMedia } from '../../utils/medias'
export default {
async asyncData({ $strapi, params }) {
const matchingAlbums = await $strapi.find('albums', {
slug: params.slug,
})
const images = []
matchingAlbums[0].photos[0].image.map((item) =>
images.push(getStrapiMedia(`${item.url}`))
)
return {
images,
album: matchingAlbums[0],
imageIndex: null,
}
},
data() {
return {
justifiedOptions: {
targetRowHeight: 105,
boxSpacing: 2,
},
}
},
methods: {
getStrapiMedia,
},
}
</script>
How to use it with vue-justified-layout
i tried to implent the basic one but i am getting the following error
this is the original code