56 lines
1.5 KiB
Plaintext
56 lines
1.5 KiB
Plaintext
---
|
|
export const prerender = false;
|
|
import "../../styles/detail.css";
|
|
import ExifReader from "exifreader";
|
|
import Layout from "../../components/Layout.astro";
|
|
import { Photo } from "../../models/photo";
|
|
const { filename } = Astro.params;
|
|
import { PHOTO_DIR_ABSOLUTE_PATH } from "astro:env/server";
|
|
import { initPhoto, initPhotos } from "../../misc";
|
|
|
|
const relativePath = `../../assets/IMG/${filename}`;
|
|
const allImages: any = import.meta.glob("../../assets/IMG/*.JPG", {
|
|
eager: true,
|
|
});
|
|
const imageImport = allImages[relativePath];
|
|
let p: Photo = new Photo();
|
|
|
|
if (imageImport && filename) {
|
|
const absolutePath = `${PHOTO_DIR_ABSOLUTE_PATH}/${filename}`;
|
|
const tags = await ExifReader.load(absolutePath);
|
|
|
|
p = initPhoto(
|
|
imageImport,
|
|
(p.description = tags.title
|
|
? tags.title.description
|
|
: "Aucune description disponible"),
|
|
(p.model = tags.Model
|
|
? tags.Model.description
|
|
: "Aucun model d'appareil photo disponible"),
|
|
filename,
|
|
);
|
|
} else {
|
|
return Astro.redirect("/");
|
|
}
|
|
---
|
|
|
|
<Layout>
|
|
<article>
|
|
<h1>{p.filename}</h1>
|
|
<main>
|
|
<a href={p.src} target="_blank">
|
|
<img
|
|
src={p.src}
|
|
alt={p.description}
|
|
title="Ouvrir l'image dans un nouvel onglet"
|
|
/>
|
|
</a>
|
|
<div>
|
|
<p><strong>Description de l'image : </strong>{p.description}</p>
|
|
<p><strong>Modèle de l'appareil : </strong>{p.model}</p>
|
|
<p><strong>Dimension de l'image : </strong>{p.width}x{p.height}</p>
|
|
</div>
|
|
</main>
|
|
</article>
|
|
</Layout>
|