-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathSponsorCard.astro
More file actions
174 lines (148 loc) · 4.65 KB
/
Copy pathSponsorCard.astro
File metadata and controls
174 lines (148 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
import { type CollectionEntry, getEntry } from "astro:content";
import { Image } from "astro:assets";
import { sponsorLogos } from "@data/sponsorLogos";
import Icon from "@ui/Icon.astro";
import SocialLinks from "@components/SocialLinks.astro";
const { sponsor: sponsorId, showJobs=false, showLinks=true } = Astro.props;
const sponsor = await getEntry("sponsors", sponsorId);
if (!sponsor) {
throw new Error(`Sponsor with ID "${sponsorId}" not found`);
}
const {
name: title,
url: website,
location,
industry,
description,
socials,
tier,
logo_padding = false,
draft
} = sponsor.data;
const jobFiles = import.meta.glob("../content/sponsors/*/!(index).md");
const sponsorsJobsMap = {};
for (const path in jobFiles) {
const match = path.match(/\.\.\/content\/sponsors\/([^/]+)\/([^/]+)\.md$/);
if (match) {
const sponsorId = match[1];
if (!sponsorsJobsMap[sponsorId]) sponsorsJobsMap[sponsorId] = [];
sponsorsJobsMap[sponsorId].push(
await getEntry("jobs", `${sponsorId}/${match[2]}`),
);
}
}
const jobs: CollectionEntry<"jobs">[] = sponsorsJobsMap[sponsor.id];
const isSponsorPage = Astro.url.pathname == `/sponsor/${sponsor.id}`;
const logo = sponsorLogos[sponsor.id];
---
<div
class=`lg:max-w-[400px] flex flex-col gap-6 p-6 rounded-lg shadow-md bg-[var(--color-surface-subtle)] mb-6 ${draft ? "draft": "no-draft"}`
>
<div class="w-full flex justify-center items-center md:items-center min-h-[140px] bg-white rounded-lg p-4">
{
logo && (
<Image
src={logo}
alt={`${title} Logo`}
style={{
minWidth: "250px",
maxHeight: "120px",
objectFit: "contain",
padding: logo_padding ? logo_padding : undefined,
}}
/>
)
}
</div>
{
description && (
<div class="flex-1">
<h2 id=`sponsor-${sponsorId}` class="sponsor text-2xl font-bold mb-2 ">
{ !isSponsorPage && tier !== 'Partners' && (tier === "Diamond" || tier === "Platinum" || sponsor.data.page) ?
<a href={`/sponsor/${sponsor.id}`}>
{title}
</a> :
<>{title}</>
}
</h2>
<p class="text-[var(--color-text-muted)] mb-4">
{industry} {industry && location && <>—</>} {location}
</p>
<p class="py-6 " style="border: 0 solid var(--color-border); border-width: 1px 0 0 0;">{description}</p>
{showJobs && jobs && (
<div class="py-6 " style="border: 0 solid var(--color-border); border-width: 1px 0 0 0;">
<h3 class="text-xl font-semibold">Job offers</h3>
<ul class="list-disc list-inside" >
{Object.values(jobs).map((job) => (
<li >
<a href={`/sponsor/${job.id}`}>{job.data.title}</a>
</li>
))}
</ul>
</div>
)}
</div>
)
}
<div>
{website && (
<div class="website-btn-container flex flex-col sm:flex-row justify-center gap-2 mt-4">
{ !isSponsorPage && sponsor.body && tier && (tier === "Diamond" || tier === "Platinum" || sponsor.data.page) &&
<a href={`/sponsor/${sponsor.id}`} class="website-btn-outline">
About {title}
</a>
}
<a href={website} target="_blank" rel="noopener noreferrer" class="website-btn ">
Visit Website <span class="pl-2"><Icon name="external-link" /></span>
</a>
</div>
)}
{ (tier !== "Partners" || showLinks) &&
<SocialLinks socials={socials} />
}
</div>
</div>
<style>
/* Website button styles */
.website-btn-container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
}
.website-btn, .website-btn-outline {
display: inline-block;
padding: 8px 24px;
margin: 0 0 12px 0;
color: var(--color-text-primary);
border-radius: 9999px;
border: 1px solid transparent;
text-decoration: none;
transition: all 0.1s ease;
}
.website-btn-outline {
border: 1px solid var(--color-blue);
}
.website-btn {
background: linear-gradient(to right, var(--color-blue), oklch(0.511 0.234 276.9) /* #4f46e5 */);
box-shadow: 0 2px 4px oklch(0 0 0 / 0.1); /* rgba(0,0,0,0.1) */
font-weight: 700;
}
.website-btn-outline {
color: var(--color-blue);
}
.website-btn:hover , .website-btn-outline:hover {
text-decoration: underline;
}
li {
list-style-type:disc;
list-style-position: inside;
}
h2 a, li a {
text-decoration: underline;
}
h2 a:hover, li a:hover {
color:var(--color-primary-hover);
}
</style>