Moved from gitlab to gitea
Publish Docker image / Build and Push Docker image (release) Successful in 2m48s
Publish Docker image / Build and Push Docker image (release) Successful in 2m48s
This commit is contained in:
+8
-11
@@ -2,28 +2,25 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import sizeOf from 'image-size';
|
||||
import sharp from 'sharp';
|
||||
import PhotoGallery from '@/app/components/PhotoGallery';
|
||||
|
||||
async function getImages() {
|
||||
const galleryDir = path.join(process.cwd(), 'public/gallery');
|
||||
const files = fs.readdirSync(galleryDir);
|
||||
const images = files
|
||||
.filter((file) => file.endsWith('.jpg') || file.endsWith('.png') || file.endsWith('.jpeg'))
|
||||
.map((file) => {
|
||||
const imagePromises = files
|
||||
.filter((file) => file.match(/\.(jpg|jpeg|png)$/i))
|
||||
.map(async (file) => {
|
||||
const filePath = path.join(galleryDir, file);
|
||||
const buffer = fs.readFileSync(filePath);
|
||||
const dimensions = sizeOf(buffer);
|
||||
|
||||
const metadata = await sharp(filePath).metadata();
|
||||
return {
|
||||
src: `/gallery/${file}`,
|
||||
width: dimensions.width || 1000,
|
||||
height: dimensions.height || 1000,
|
||||
width: metadata.width || 1000,
|
||||
height: metadata.height || 1000,
|
||||
name: file,
|
||||
};
|
||||
});
|
||||
|
||||
return images;
|
||||
return Promise.all(imagePromises);
|
||||
}
|
||||
|
||||
export default async function GalleryPage() {
|
||||
|
||||
Reference in New Issue
Block a user