Skip to content

Commit 4ef3440

Browse files
author
MerchantPug
committed
chore: Update to match new Mod Garden API values.
1 parent a8045b5 commit 4ef3440

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/components/ProjectCard.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
import type {
33
Award,
4-
EventSubmission,
5-
ModGardenEvents,
4+
ModGardenEvent,
65
Project,
76
} from "../ts/ModGardenAPI";
87
import type { Mod } from "../ts/ModrinthHelper";
@@ -11,7 +10,7 @@ import { getModrinthModData } from "../ts/ModGardenAPI";
1110
interface Props {
1211
submission: Project;
1312
awards?: Award[];
14-
events?: ModGardenEvents[];
13+
events?: ModGardenEvent[];
1514
}
1615
1716
const { submission, events, awards } = Astro.props;

src/pages/events/[event].astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import {
44
getEvent,
55
getEventProjects,
66
} from "../../ts/ModGardenAPI";
7-
import type { ModGardenEvents, ResponseError } from "../../ts/ModGardenAPI";
7+
import type { ModGardenEvent, ResponseError } from "../../ts/ModGardenAPI";
88
99
const { event } = Astro.params;
1010
11-
let eventData: ModGardenEvents | ResponseError = await getEvent(event!);
11+
let eventData: ModGardenEvent | ResponseError = await getEvent(event!);
1212
1313
if (!eventData || "error" in eventData) {
1414
Astro.response.status = 404;
1515
Astro.response.statusText = "Event not found";
1616
}
17-
eventData = eventData as ModGardenEvents;
17+
eventData = eventData as ModGardenEvent;
1818
const projects = await getEventProjects(eventData.id);
1919
---
2020

src/pages/events/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const events = await getEvents();
2121
<div class="border-0 border-b-4 border-leaf-200 text-lg font-semibold text-black dark:text-white">
2222
{modGardenEvent.display_name}
2323
</div>
24-
<div class="italic">{modGardenEvent.description}</div>
24+
<div class="italic">{modGardenEvent.description.split("\n")[0]}</div>
2525
</div>
2626
</a>
2727
))

src/pages/user/[user].astro

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
import Layout from "../../layouts/Layout.astro";
3-
import { Image } from "astro:assets";
43
import {
54
getEvents,
65
getUserAwards,
@@ -10,7 +9,7 @@ import {
109
} from "../../ts/ModGardenAPI";
1110
import type {
1211
UserData,
13-
ModGardenEvents,
12+
ModGardenEvent,
1413
Award,
1514
} from "../../ts/ModGardenAPI";
1615
import ProjectCard from "../../components/ProjectCard.astro";
@@ -33,15 +32,15 @@ const events = await getEvents();
3332
for (const submission of submissions) {
3433
uniqueEvents.add(submission.event);
3534
}
36-
const projectToEventsMap: Map<string, ModGardenEvents[]> = new Map();
35+
const projectToEventsMap: Map<string, ModGardenEvent[]> = new Map();
3736
for (const submission of submissions) {
3837
if (!projectToEventsMap.has(submission.project_id)) {
3938
projectToEventsMap.set(submission.project_id, []);
4039
}
4140
projectToEventsMap
4241
.get(submission.project_id)
4342
?.push(
44-
events.find((event) => event.id === submission.event) as ModGardenEvents,
43+
events.find((event) => event.id === submission.event) as ModGardenEvent,
4544
);
4645
}
4746
const images = import.meta.glob<{ default: ImageMetadata }>(

src/ts/ModGardenAPI.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export type UserData = {
1515
id: string;
1616
username: string;
1717
display_name: string;
18+
avatar_url?: string;
19+
pronouns?: string;
1820
discord_id: string;
1921
modrinth_id?: string;
2022
created: number;
@@ -37,17 +39,19 @@ export type Project = {
3739
modrinth_id: string;
3840
attributed_to: string;
3941
authors: string[];
42+
builders: string[];
4043
};
4144

42-
export type ModGardenEvents = {
45+
export type ModGardenEvent = {
4346
id: string;
4447
slug: string;
4548
display_name: string;
4649
description: string;
4750
minecraft_version: string;
4851
loader: string;
4952
loader_version: string;
50-
started: number;
53+
start_time: string;
54+
end_time: string;
5155
};
5256
export type AwardTier = "COMMON" | "UNCOMMON" | "RARE" | "LEGENDARY";
5357
export type Award = {
@@ -93,18 +97,18 @@ export async function getUserData(
9397

9498
export async function getEvent(
9599
slug: string,
96-
): Promise<ModGardenEvents | ResponseError> {
100+
): Promise<ModGardenEvent | ResponseError> {
97101
return await fetch(api_url + "event/" + slug)
98102
.then((response) => response.json())
99103
.then((data) =>
100-
data.error ? (data as ResponseError) : (data as ModGardenEvents),
104+
data.error ? (data as ResponseError) : (data as ModGardenEvent),
101105
);
102106
}
103107

104-
export async function getEvents(): Promise<ModGardenEvents[]> {
108+
export async function getEvents(): Promise<ModGardenEvent[]> {
105109
return await fetch(api_url + "events")
106110
.then((response) => response.json())
107-
.then((data) => data as ModGardenEvents[]);
111+
.then((data) => data as ModGardenEvent[]);
108112
}
109113

110114
export async function getSubmission(

0 commit comments

Comments
 (0)