mirror of
https://github.com/DerTyp7/explainegy-nextjs.git
synced 2026-07-31 15:49:04 +02:00
sdf
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
"use client";
|
||||
import React, { useState } from "react";
|
||||
import { Gallery as ReactGridGallery, Image as ImageType, ThumbnailImageProps } from "react-grid-gallery";
|
||||
import Image from "next/image";
|
||||
const ImageComponent = (props: ThumbnailImageProps) => {
|
||||
const { src, alt, style, title } = props.imageProps;
|
||||
const { width, height } = props.item;
|
||||
|
||||
return (
|
||||
<Image
|
||||
alt={alt}
|
||||
src={src}
|
||||
title={title || ""}
|
||||
width={width}
|
||||
height={height}
|
||||
onClick={() => {
|
||||
window.open(src);
|
||||
}}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default function Gallery({ images }: { images: ImageType[] }) {
|
||||
return <ReactGridGallery images={images} enableImageSelection={false} thumbnailImageComponent={ImageComponent} />;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import React from "react";
|
||||
import { Image } from "@prisma/client";
|
||||
import { Image as GalleryImage } from "react-grid-gallery";
|
||||
import urlJoin from "url-join";
|
||||
import { apiUrl } from "../../../global";
|
||||
import Gallery from "./Gallery";
|
||||
|
||||
async function getImages(): Promise<GalleryImage[]> {
|
||||
const result = await fetch(urlJoin(apiUrl, `images`), {
|
||||
cache: "no-cache",
|
||||
});
|
||||
const imageData: Image[] = await result.json();
|
||||
|
||||
return imageData.map((img, i) => ({
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
src: img.url,
|
||||
caption: img.name,
|
||||
}));
|
||||
}
|
||||
|
||||
export default async function AdminImagesPage() {
|
||||
return <Gallery images={await getImages()} />;
|
||||
}
|
||||
Reference in New Issue
Block a user