Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions 2025/src/components/Sponsors/Company.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
---
import type { ImageMetadata } from "astro";

// import.meta.globで画像をlazyロード
const images = import.meta.glob<{ default: ImageMetadata }>(
"/src/assets/sponsors/*.{png,svg}",
);

type Props = {
sponsor: {
rank: "platinum" | "gold" | "silver" | "bronze";
Expand All @@ -11,14 +18,14 @@ type Props = {
const props = Astro.props;
const { rank, name, url, image } = props.sponsor;

const imagePath = `/src/assets/sponsors/${image}`;
let imageUrl = "";
try {
const module = await import(
/* @vite-ignore */ `../../assets/sponsors/${image}?url`
);
imageUrl = module.default;
} catch (e) {
console.error(`Icon not found: ${image}`);

if (images[imagePath]) {
const imageModule = await images[imagePath]();
imageUrl = imageModule.default.src;
} else {
console.error(`Image not found: ${imagePath}`);
}

// ランクごとのスタイル設定
Expand Down