Skip to content

Commit d10618f

Browse files
committed
Combine sponsors and companies.
1 parent b1a7c94 commit d10618f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+154
-64
lines changed

src/components/CompanyCard.astro

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
import { type CollectionEntry, getEntry } from "astro:content";
3-
import { marked } from 'marked';
3+
import { Image } from "astro:assets";
4+
import { companyLogos } from "@data/companyLogos";
45
56
67
const { company } = Astro.props;
7-
const { title, logo, website, location, industry, description, socials } = company.data;
8+
const { name: title, url:website, location, industry, description, socials, logo_padding=false } = company.data;
89
910
const jobFiles = import.meta.glob('../content/companies/*/!(index).md');
1011
const companiesJobsMap = {};
@@ -18,26 +19,31 @@ for (const path in jobFiles) {
1819
}
1920
}
2021
21-
const jobs = companiesJobsMap[company.id];
22+
const jobs: CollectionEntry<"jobs"> = companiesJobsMap[company.id];
2223
2324
const isCompanyPage = Astro.url.pathname == `/company/${company.id}`;
2425
25-
const html = marked.parse(company.body);
26+
const logo = companyLogos[company.id];
27+
28+
const link = description ? `/company/${company.id}` : website;
2629
2730
---
2831

2932
<div class="lg:max-w-[400px] flex flex-col gap-6 p-6 rounded-lg shadow-md bg-white text-black">
3033
<div class="w-full flex justify-center items-center md:items-center ">
31-
<img src={logo} alt={title + " Logo"} class="max-h-[200px] object-contain" />
34+
{logo && (
35+
<a href={link}>
36+
<Image
37+
src={logo}
38+
alt={`${title} Logo`}
39+
style={{ minWidth: "250px", maxHeight: "120px", objectFit: "contain", padding: logo_padding ? logo_padding : undefined, }}
40+
/>
41+
</a>
42+
)}
3243
</div>
44+
{ description &&
3345
<div class="flex-1">
34-
<h2 class="text-2xl font-bold mb-2">
35-
{ isCompanyPage ?
36-
<>{title}</> :
37-
<a href={`/company/${company.id}`}>{title}</a>
38-
}
39-
</h2>
40-
<p class="text-gray-600 mb-2">{industry}{location}</p>
46+
<p class="text-gray-600 mb-2">{industry} {industry && location && <>—</>} {location}</p>
4147
<p class="mb-4">{description}</p>
4248

4349
<div class="flex space-x-4 mb-4">
@@ -58,7 +64,8 @@ const html = marked.parse(company.body);
5864
</div>
5965
)}
6066

61-
{ !isCompanyPage && <a class="btn btn-primary mt-6 inline-block" href={`/company/${company.id}`}>Who We Are</a>}
67+
{ !isCompanyPage && company.body && <a class="btn btn-primary mt-6 inline-block" href={`/company/${company.id}`}>Who We Are</a>}
6268
</div>
69+
}
6370

6471
</div>

src/components/CompanyCardBody.astro

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
---
2-
import { type CollectionEntry, getEntry } from "astro:content";
3-
import { marked } from 'marked';
4-
5-
6-
const { company, full=false, openings=false } = Astro.props;
7-
const { title, logo, website, location, industry, description, socials } = company.data;
82
9-
const jobFiles = import.meta.glob('../content/companies/*/!(index).md');
10-
const jobs: CollectionEntry<'jobs'>[] = [];
11-
12-
for (const path in jobFiles) {
13-
const match = path.match(/\.\.\/content\/companies\/([^/]+)\/([^/]+)\.md$/);
14-
if (match) {
15-
const companyId = company.id;
16-
const entry = await getEntry('jobs', `${companyId}/${match[2]}`);
17-
if (entry) {
18-
jobs.push(entry);
19-
}
20-
}
21-
}
22-
23-
const html = marked.parse(company.body);
3+
import { marked } from 'marked';
4+
const { company } = Astro.props;
5+
const html = company.body ? marked.parse(company.body) : "";
246
257
---
268

src/components/sponsors/sponsor-tier.astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { getCollection } from "astro:content";
33
import { Image } from "astro:assets";
44
5-
type Sponsor = Awaited<ReturnType<typeof getCollection<"sponsors">>>[0];
5+
type Sponsor = Awaited<ReturnType<typeof getCollection<"companies">>>[0];
66
77
export interface Props {
88
tier: {
@@ -13,6 +13,9 @@ export interface Props {
1313
top?: boolean;
1414
}
1515
16+
17+
import { companyLogos } from "@data/companyLogos";
18+
1619
const { tier, top } = Astro.props;
1720
---
1821

@@ -42,7 +45,7 @@ const { tier, top } = Astro.props;
4245
class="pb-8"
4346
>
4447
<Image
45-
src={sponsor.data.image}
48+
src={companyLogos[sponsor.id]}
4649
alt={sponsor.data.name}
4750
width={500}
4851
class="max-w-[250px] max-h-[120px]"

src/components/sponsors/sponsors.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const tiers = [
2323
"Partners"
2424
] as const;
2525
26-
const sponsors = await getCollection("sponsors");
26+
const sponsors = await getCollection("companies");
2727
2828
let hasSponsors = false;
2929
Lines changed: 3 additions & 1 deletion

src/content/companies/acme-corp/index.md

Lines changed: 2 additions & 3 deletions
File renamed without changes.

src/content/companies/acme-corp2/index.md

Lines changed: 2 additions & 3 deletions
File renamed without changes.
Lines changed: 2 additions & 0 deletions
File renamed without changes.
Lines changed: 2 additions & 1 deletion
Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Lines changed: 3 additions & 0 deletions

src/content/config.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ const deadlines = defineCollection({
3838
}),
3939
});
4040

41-
const sponsors = defineCollection({
42-
type: "data",
43-
schema: ({ image }) =>
44-
z.object({
45-
name: z.string(),
46-
url: z.string(),
47-
image: image(),
48-
tier: z.enum(tiers),
49-
}),
50-
});
51-
5241
const keynoters = defineCollection({
5342
type: "content",
5443
schema: ({ image }) =>
@@ -219,19 +208,20 @@ const days = defineCollection({
219208
const companies = defineCollection({
220209
loader: glob({ pattern: "*/index.md", base: "./src/content/companies" }),
221210
schema: z.object({
222-
title: z.string(),
223-
logo: z.string().optional(),
224-
website: z.string().url(),
225-
location: z.string(),
226-
industry: z.string(),
227-
description: z.string(),
211+
name: z.string(),
212+
url: z.string().url(),
213+
tier: z.string().optional(),
214+
location: z.string().optional(),
215+
industry: z.string().optional(),
216+
description: z.string().optional(),
228217
socials: z
229218
.object({
230219
linkedin: z.string().url().optional(),
231220
twitter: z.string().url().optional(),
232221
})
233222
.optional(),
234223
jobs: z.array(z.string()).optional(),
224+
logo_padding: z.string().optional(),
235225
}),
236226
});
237227

@@ -256,7 +246,6 @@ export const collections = {
256246
days,
257247
pages,
258248
deadlines,
259-
sponsors,
260249
sessions,
261250
speakers,
262251
keynoters,

src/content/sponsors/.gitkeep

Whitespace-only changes.

src/data/companyLogos.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const logoImports = import.meta.glob<true, string, { default: ImageMetadata }>(
2+
"../content/companies/*/{logo,*}.@(svg|png|webp)",
3+
{ eager: true }
4+
);
5+
6+
export const companyLogos: Record<string, ImageMetadata> = {};
7+
8+
for (const path in logoImports) {
9+
const match = path.match(
10+
/\/companies\/([^/]+)\/(?:\1|logo)\.(svg|png|webp)$/
11+
);
12+
if (match) {
13+
const companyId = match[1];
14+
companyLogos[companyId] = logoImports[path].default;
15+
}
16+
}

0 commit comments

Comments
 (0)