|
1 | 1 | --- |
2 | | -import DeadlineCard from "./deadline-card.astro"; |
3 | | -import Headline from "@ui/Headline.astro"; |
4 | 2 | import { getCollection } from "astro:content"; |
5 | | -import Section from "@ui/Section.astro"; |
| 3 | +import { Image } from "astro:assets"; |
6 | 4 |
|
7 | | -let deadlines = await getCollection("deadlines"); |
8 | | -deadlines = deadlines |
| 5 | +let deadlineEntries = await getCollection("deadlines"); |
| 6 | +deadlineEntries = deadlineEntries |
| 7 | + .filter((d) => !d.data.disabled) |
9 | 8 | .sort((a, b) => a.slug.localeCompare(b.slug)) |
10 | 9 | .reverse() |
11 | 10 | .slice(0, 3); |
| 11 | +
|
| 12 | +const cards = await Promise.all( |
| 13 | + deadlineEntries.map(async (entry) => { |
| 14 | + const { Content } = await entry.render(); |
| 15 | + return { data: entry.data, Content }; |
| 16 | + }) |
| 17 | +); |
12 | 18 | --- |
13 | 19 |
|
14 | | -<Section> |
15 | | - <Headline id="updates" title="Updates" center="true" /> |
16 | | - <section class="justify-center gap-6 flex flex-wrap px-6"> |
17 | | - {deadlines.map((deadline) => <DeadlineCard id={deadline.slug} />)} |
18 | | - </section> |
19 | | -</Section> |
| 20 | +<section class="sec-wrap news-section" id="updates"> |
| 21 | + <div class="section-inner"> |
| 22 | + |
| 23 | + <div class="news-grid"> |
| 24 | + {cards.map(({ data, Content }) => ( |
| 25 | + <div class="news-card"> |
| 26 | + {data.image && ( |
| 27 | + <div class="news-image"> |
| 28 | + <Image |
| 29 | + src={data.image} |
| 30 | + alt={data.title} |
| 31 | + width={600} |
| 32 | + height={375} |
| 33 | + class="news-img" |
| 34 | + loading="lazy" |
| 35 | + /> |
| 36 | + </div> |
| 37 | + )} |
| 38 | + <div class="news-title">{data.title}</div> |
| 39 | + <div class="news-desc"><Content /></div> |
| 40 | + <a |
| 41 | + href={data.url} |
| 42 | + class="news-cta" |
| 43 | + style={data.disabled ? "opacity: 0.4; pointer-events: none;" : ""} |
| 44 | + > |
| 45 | + {data.subtitle} |
| 46 | + </a> |
| 47 | + </div> |
| 48 | + ))} |
| 49 | + </div> |
| 50 | + |
| 51 | + </div> |
| 52 | +</section> |
| 53 | + |
| 54 | +<style> |
| 55 | + .sec-wrap { |
| 56 | + color: #fff; |
| 57 | + position: relative; |
| 58 | + overflow: hidden; |
| 59 | + } |
| 60 | + |
| 61 | + .news-section { |
| 62 | + background: var(--color-section-bg, #080f1a); |
| 63 | + } |
| 64 | + |
| 65 | + .section-inner { |
| 66 | + max-width: 1200px; |
| 67 | + margin: 0 auto; |
| 68 | + padding: 4rem 2rem; |
| 69 | + } |
| 70 | + |
| 71 | + .news-grid { |
| 72 | + display: grid; |
| 73 | + grid-template-columns: repeat(3, 1fr); |
| 74 | + gap: 1.25rem; |
| 75 | + } |
| 76 | + |
| 77 | + .news-card { |
| 78 | + padding: 1.4rem 0; |
| 79 | + display: flex; |
| 80 | + flex-direction: column; |
| 81 | + gap: 0.75rem; |
| 82 | + text-align: center; |
| 83 | + align-items: center; |
| 84 | + } |
| 85 | + |
| 86 | + .news-image { |
| 87 | + width: 100%; |
| 88 | + border-radius: 8px; |
| 89 | + overflow: hidden; |
| 90 | + } |
| 91 | + |
| 92 | + .news-img { |
| 93 | + width: 100%; |
| 94 | + height: auto; |
| 95 | + display: block; |
| 96 | + border-radius: 8px; |
| 97 | + } |
| 98 | + |
| 99 | + .news-title { |
| 100 | + font-family: var(--font-archivo, 'Roboto', sans-serif); |
| 101 | + font-size: 1.4rem; |
| 102 | + color: var(--color-cream, #fff5f0); |
| 103 | + line-height: 1.25; |
| 104 | + } |
| 105 | + |
| 106 | + .news-desc { |
| 107 | + font-size: 1.05rem; |
| 108 | + line-height: 1.6; |
| 109 | + color: var(--color-text-secondary-dark, rgba(255,255,255,0.78)); |
| 110 | + flex: 1; |
| 111 | + } |
| 112 | + |
| 113 | + .news-cta { |
| 114 | + display: inline-block; |
| 115 | + margin-top: 0.75rem; |
| 116 | + padding: 0.6rem 1.5rem; |
| 117 | + border: 1px solid var(--color-accent, #f0c040); |
| 118 | + border-radius: 2px; |
| 119 | + color: var(--color-accent, #f0c040); |
| 120 | + font-family: var(--font-archivo, 'Roboto', sans-serif); |
| 121 | + font-size: 0.95rem; |
| 122 | + text-decoration: none; |
| 123 | + transition: opacity 0.2s; |
| 124 | + background: transparent; |
| 125 | + align-self: center; |
| 126 | + } |
| 127 | + |
| 128 | + .news-cta:hover { |
| 129 | + opacity: 0.8; |
| 130 | + } |
| 131 | + |
| 132 | + @media (max-width: 860px) { |
| 133 | + .news-grid { |
| 134 | + grid-template-columns: repeat(2, 1fr); |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + @media (max-width: 480px) { |
| 139 | + .news-grid { |
| 140 | + grid-template-columns: 1fr; |
| 141 | + } |
| 142 | + } |
| 143 | +</style> |
0 commit comments