refactor: use import.meta to resolve photos url

use import.meta to resolve photos url both locally and in prod
suppression-manon-adrien
Sebastien Arod 2024-06-07 12:18:09 +02:00
parent a9e742151e
commit 72bdb6ca78
4 changed files with 28 additions and 90 deletions

View File

@ -1,19 +1,18 @@
import "mapbox-gl/dist/mapbox-gl.css";
import React from "react";
import { RouterProvider } from "react-router-dom";
import { ViewMode } from "./routes/ViewMode";
import { DisplayModeContext } from "./context/DisplayModeContext";
import { HomeContext } from "./context/HomeContext";
import { router } from "./router";
import "mapbox-gl/dist/mapbox-gl.css";
import "./style/SquareSpace/vars.css";
import "./style/SquareSpace/global.css";
import "./style/SquareSpace/blocks.css";
import "./style/SquareSpace/table.css";
import "./style/SquareSpace/video.css";
import "./style/thumbs.css";
import "./style/row.css";
import "./photos";
import "./declarations";
import { router } from "./router";
import { ViewMode } from "./routes/ViewMode";
import "./style/SquareSpace/blocks.css";
import "./style/SquareSpace/global.css";
import "./style/SquareSpace/table.css";
import "./style/SquareSpace/vars.css";
import "./style/SquareSpace/video.css";
import "./style/row.css";
import "./style/thumbs.css";
interface Props {
defaultViewMode: ViewMode;

View File

@ -1,4 +1,16 @@
import { Resistant } from "./Resistant";
export const getResistantPhotoUrl = (resistant: Resistant) =>
`https://enfance-libre.frama.io/resistants/assets/${resistant.id}.jpg`;
const photoUrls = import.meta.glob("./photos/*.jpg", {
query: "?url",
eager: true,
import: "default",
});
export const getResistantPhotoUrl = (resistant: Resistant): string => {
const url = new URL(
photoUrls[`./photos/${resistant.id}.jpg`] as string,
import.meta.url
).toString();
return url;
};

View File

@ -1,76 +0,0 @@
import "./alexandre-julie.jpg";
import "./amelie-vincent.jpg";
import "./andrea-gherard.jpg";
import "./andrea-jerome.jpg";
import "./angelique-jonathan.jpg";
import "./anne-laure-damien.jpg";
import "./anne-lise-marc.jpg";
import "./arnaud-pauline.jpg";
import "./audrey-jeremie.jpg";
import "./audreyanne-michael.jpg";
import "./benedicte-yves.jpg";
import "./bertrand-angelique.jpg";
import "./caroline-gael.jpg";
import "./caroline-maxime-gregory.jpg";
import "./cecile-jordan.jpg";
import "./celine-fabrice.jpg";
import "./david-coralie.jpg";
import "./deborah-florian.jpg";
import "./elodie-mathieu.jpg";
import "./emeline-sebastien.jpg";
import "./emmanuelle-philippe.jpg";
import "./fleur-gael.jpg";
import "./florence-alexis.jpg";
import "./florence-pierre-alexandre.jpg";
import "./guilhem-eglantine.jpg";
import "./helene-d.jpg";
import "./helene-f.jpg";
import "./helene-volodia.jpg";
import "./isabelle-julio.jpg";
import "./isabelle-nicolas.jpg";
import "./jenny-thierry.jpg";
import "./jerome-gwenaelle.jpg";
import "./jonathan-caroline.jpg";
import "./julia-dawy.jpg";
import "./julie-jeanchristophe.jpg";
import "./karene-jalil.jpg";
import "./laure-labadie.jpg";
import "./lea-frederic.jpg";
import "./lola-morgan.jpg";
import "./louise-lionel.jpg";
import "./manon-adrien.jpg";
import "./marianne-denis.jpg";
import "./marie-alexis.jpg";
import "./marie-julien.jpg";
import "./marie-matthieu.jpg";
import "./marina-frederic.jpg";
import "./marina-romain.jpg";
import "./marion-quentin.jpg";
import "./marlene-benjamin.jpg";
import "./mathilde-cyril.jpg";
import "./mathilde-dorian.jpg";
import "./mathilde-thomas.jpg";
import "./maylis-benoit.jpg";
import "./myriam-timothee.jpg";
import "./nicolas-elodie.jpg";
import "./olivia-pascoal.jpg";
import "./ophelie-sylvain.jpg";
import "./perrina-benjamin.jpg";
import "./perrine-francois.jpg";
import "./philomene-mathieu.jpg";
import "./rachel-bastien.jpg";
import "./ramin-marjorie.jpg";
import "./roseline-jonathan.jpg";
import "./samuel-laurence.jpg";
import "./sarah-jerome.jpg";
import "./sebastien-marie.jpg";
import "./sita-pascal.jpg";
import "./sonia-jeanchristophe.jpg";
import "./stephanie-david.jpg";
import "./sultane-mehmet.jpg";
import "./sylvaine-olivier.jpg";
import "./valene-emilien.jpg";
import "./virginie-eric.jpg";
import "./virginie-gaetan.jpg";
import "./virginie-mikael.jpg";
import "./virginie-yves.jpg";

View File

@ -14,7 +14,10 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"types": [
"vite/client" // Needed for import.meta.glob
]
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]