Commit 4fc816af authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

fix: Update Graphic component support for organizations

parent f76a01dd
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -6,11 +6,11 @@ import { TbTextCaption } from "react-icons/tb";
import Lightbox from "../components/Lightbox.astro";
import GraphicCornerLabel from "./GraphicCornerLabel.astro";

const { project, data, title } = Astro.props;
const { path, data } = Astro.props;
const { href, caption } = data;
const DEFAULT_IMAGE_PATH = "/src/assets/default.png";
const images = import.meta.glob<{ default: ImageMetadata }>("src/**/*.{png,jpg,jpeg}", { import: 'default' });
const re = new RegExp(`/src/data/project/${project}/${href}`);
const re = new RegExp(`/src/data/${path}/${href}`);
const maybeImagePath = Object.keys(images).find((key) => re.test(key));
const src = images[maybeImagePath ? maybeImagePath : DEFAULT_IMAGE_PATH]();
---
@@ -23,7 +23,7 @@ const src = images[maybeImagePath ? maybeImagePath : DEFAULT_IMAGE_PATH]();
</script>
<div class="graphic-wrapper">
    <GraphicCornerLabel />
    <Image src={src} title={title} alt={title} width={380} height={200} />
    <Image src={src} title={caption} alt={caption} width={380} height={200} />
    {
        caption && (
            <div class="graphic-caption">
@@ -34,7 +34,7 @@ const src = images[maybeImagePath ? maybeImagePath : DEFAULT_IMAGE_PATH]();
        )
    }
</div>
<Lightbox src={src} title={title} caption={caption} />
<Lightbox src={src} title={caption} caption={caption} />
<style>
    .graphic-wrapper {
        cursor: pointer;
+1 −2
Original line number Diff line number Diff line
@@ -43,8 +43,7 @@ export async function getStaticPaths() {
		<aside>
			<div>
				<Graphic
					project={organization}
					title={title}
					path={`organization/${organization}`}
					data={meta?.graphics?.[0]}
				/>
			</div>
+1 −2
Original line number Diff line number Diff line
@@ -46,8 +46,7 @@ export async function getStaticPaths() {
		<aside>
			<div>
				<Graphic
					project={project}
					title={title}
					path={`project/${project}`}
					data={meta?.graphics?.[0]}
				/>
			</div>