|
1 |
| -<div class="mb-10"> |
2 |
| - <h3 class="mb-6 text-center text-xl font-semibold md:text-2xl"> |
3 |
| - 企業スポンサー |
4 |
| - </h3> |
5 |
| - <div class="space-y-10"> |
6 |
| - <div class="space-y-6"> |
7 |
| - <h4 class="text-center text-lg font-medium">プラチナ</h4> |
8 |
| - <div class="grid grid-cols-1 justify-items-center gap-8 md:grid-cols-2"> |
9 |
| - <div class="flex flex-col items-center"> |
10 |
| - <div class="mb-3 flex h-24 items-center justify-center md:h-32"> |
11 |
| - <img alt="Acme Inc." class="max-h-full max-w-full object-contain" /> |
12 |
| - </div> |
13 |
| - <h4 class="text-base font-medium text-gray-800 md:text-lg"> |
14 |
| - Acme Inc. |
15 |
| - </h4> |
16 |
| - </div> |
17 |
| - <div class="flex flex-col items-center"> |
18 |
| - <div class="mb-3 flex h-24 items-center justify-center md:h-32"> |
19 |
| - <img alt="TechCorp" class="max-h-full max-w-full object-contain" /> |
20 |
| - </div> |
21 |
| - <h4 class="text-base font-medium text-gray-800 md:text-lg"> |
22 |
| - TechCorp |
23 |
| - </h4> |
24 |
| - </div> |
25 |
| - </div> |
26 |
| - </div> |
27 |
| - <div class="space-y-6"> |
28 |
| - <h4 class="text-center text-lg font-medium">ゴールド</h4> |
29 |
| - <div class="grid grid-cols-2 justify-items-center gap-6 md:grid-cols-3"> |
30 |
| - <div class="flex flex-col items-center"> |
31 |
| - <div class="mb-2 flex h-20 items-center justify-center md:h-24"> |
32 |
| - <img |
33 |
| - alt="DevSolutions" |
34 |
| - class="max-h-full max-w-full object-contain" |
35 |
| - /> |
36 |
| - </div> |
37 |
| - <h4 class="text-sm font-medium text-gray-800 md:text-base"> |
38 |
| - DevSolutions |
39 |
| - </h4> |
40 |
| - </div> |
41 |
| - <div class="flex flex-col items-center"> |
42 |
| - <div class="mb-2 flex h-20 items-center justify-center md:h-24"> |
43 |
| - <img |
44 |
| - alt="CodeMasters" |
45 |
| - class="max-h-full max-w-full object-contain" |
46 |
| - /> |
47 |
| - </div> |
48 |
| - <h4 class="text-sm font-medium text-gray-800 md:text-base"> |
49 |
| - CodeMasters |
50 |
| - </h4> |
51 |
| - </div> |
52 |
| - </div> |
53 |
| - </div> |
54 |
| - <div class="space-y-6"> |
55 |
| - <h4 class="text-center text-lg font-medium">シルバー</h4> |
56 |
| - <div class="grid grid-cols-3 justify-items-center gap-4 md:grid-cols-4"> |
57 |
| - <div class="flex flex-col items-center"> |
58 |
| - <div class="mb-2 flex h-12 items-center justify-center md:h-16"> |
59 |
| - <img alt="ByteWorks" class="max-h-full max-w-full object-contain" /> |
60 |
| - </div> |
61 |
| - <h4 class="text-center text-xs font-medium text-gray-800 md:text-sm"> |
62 |
| - ByteWorks |
| 1 | +--- |
| 2 | +import { getCollection } from "astro:content"; |
| 3 | +import Company from "./Company.astro"; |
| 4 | +import Heading from "../Heading.astro"; |
| 5 | +
|
| 6 | +const sponsorsData = await getCollection("sponsors"); |
| 7 | +
|
| 8 | +const sponsors = sponsorsData.map((sponsor) => sponsor.data); |
| 9 | +
|
| 10 | +const sponsorsByRank = sponsors.reduce( |
| 11 | + (acc, sponsor) => { |
| 12 | + if (!acc[sponsor.rank]) { |
| 13 | + acc[sponsor.rank] = []; |
| 14 | + } |
| 15 | + acc[sponsor.rank].push(sponsor); |
| 16 | + return acc; |
| 17 | + }, |
| 18 | + {} as Record<string, typeof sponsors>, |
| 19 | +); |
| 20 | +
|
| 21 | +const rankOrder = ["platinum", "gold", "silver", "bronze"]; |
| 22 | +--- |
| 23 | + |
| 24 | +<Heading>企業スポンサー</Heading> |
| 25 | +{ |
| 26 | + rankOrder.map( |
| 27 | + (rank) => |
| 28 | + sponsorsByRank[rank] && ( |
| 29 | + <> |
| 30 | + <h4 class="mb-4 text-center text-lg font-medium capitalize"> |
| 31 | + {rank} |
63 | 32 | </h4>
|
64 |
| - </div> |
65 |
| - <div class="flex flex-col items-center"> |
66 |
| - <div class="mb-2 flex h-12 items-center justify-center md:h-16"> |
67 |
| - <img alt="EditPro" class="max-h-full max-w-full object-contain" /> |
| 33 | + <div |
| 34 | + class:list={[ |
| 35 | + "mb-8 grid place-items-center gap-4", |
| 36 | + { "grid-cols-1": rank === "platinum" }, |
| 37 | + { "grid-cols-2 md:grid-cols-2": rank === "gold" }, |
| 38 | + { "grid-cols-2 md:grid-cols-3": rank === "silver" }, |
| 39 | + { "grid-cols-2 md:grid-cols-4": rank === "bronze" }, |
| 40 | + ]} |
| 41 | + > |
| 42 | + {sponsorsByRank[rank].map((sponsor) => ( |
| 43 | + <Company {sponsor} /> |
| 44 | + ))} |
68 | 45 | </div>
|
69 |
| - <h4 class="text-center text-xs font-medium text-gray-800 md:text-sm"> |
70 |
| - EditPro |
71 |
| - </h4> |
72 |
| - </div> |
73 |
| - <div class="flex flex-col items-center"> |
74 |
| - <div class="mb-2 flex h-12 items-center justify-center md:h-16"> |
75 |
| - <img alt="VimTools" class="max-h-full max-w-full object-contain" /> |
76 |
| - </div> |
77 |
| - <h4 class="text-center text-xs font-medium text-gray-800 md:text-sm"> |
78 |
| - VimTools |
79 |
| - </h4> |
80 |
| - </div> |
81 |
| - </div> |
82 |
| - </div> |
83 |
| - </div> |
84 |
| -</div> |
| 46 | + </> |
| 47 | + ), |
| 48 | + ) |
| 49 | +} |
0 commit comments