Skip to content

Commit f31476a

Browse files
fix: Sort mods alphabetically by title rather than slug, potential fix for time being rendered serverside.
1 parent a0d411f commit f31476a

File tree

4 files changed

+59
-28
lines changed

4 files changed

+59
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mod-garden-website",
33
"type": "module",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"scripts": {
66
"dev": "astro dev --api real",
77
"dev_local": "astro dev --api local",

src/components/ProjectCard.astro

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ import { getModrinthModData } from "../ts/ModGardenAPI";
66
77
interface Props {
88
submission: Project;
9+
mod?: Mod;
910
awards?: Award[];
1011
events?: ModGardenEvent[];
1112
showUserInfo?: boolean;
1213
}
1314
14-
const { submission, events, awards, showUserInfo } = Astro.props;
15+
const { submission, mod, events, awards, showUserInfo } = Astro.props;
1516
16-
const mod: Mod | undefined = await getModrinthModData(submission.modrinth_id);
17-
if (!mod) {
18-
throw new Error("Modrinth data not found: " + submission.modrinth_id);
17+
var obtainedMod = mod;
18+
if (!obtainedMod) {
19+
const lookup: Mod | undefined = await getModrinthModData(submission.modrinth_id);
20+
if (!lookup) {
21+
throw new Error("Modrinth data not found: " + submission.modrinth_id);
22+
}
23+
obtainedMod = lookup;
1924
}
2025
2126
let eventNames = "";
@@ -29,8 +34,8 @@ if (awards != undefined && awards.length > 0) {
2934
awardNames = awards.map((award) => award.display_name).join(", ");
3035
}
3136
32-
const galleryPicture = mod.gallery?.length ? mod.gallery[0] : undefined;
33-
const iconPicture = mod.icon_url ? mod.icon_url : undefined;
37+
const galleryPicture = obtainedMod.gallery?.length ? obtainedMod.gallery[0] : undefined;
38+
const iconPicture = obtainedMod.icon_url ? obtainedMod.icon_url : undefined;
3439
const projectAuthors: UserData[] = [];
3540
if (showUserInfo) {
3641
const users = submission.authors;
@@ -61,7 +66,7 @@ if (showUserInfo) {
6166
</span>
6267
<div>
6368
<h1 class="pb-1 text-lg font-bold text-black dark:text-white">
64-
{mod.title}
69+
{obtainedMod.title}
6570
</h1>
6671
{showUserInfo && (<div> By:
6772
{projectAuthors.length > 0
@@ -73,7 +78,7 @@ if (showUserInfo) {
7378
}
7479
</div>)}
7580
<span>
76-
{mod.description}
81+
{obtainedMod.description}
7782
</span>
7883
</div>
7984
</div>

src/pages/events/mod-garden/nature.astro

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
11
---
22
import Layout from "../../../layouts/Layout.astro";
3-
import Moment from "moment";
43
import { Image } from "astro:assets";
54
import ProjectCard from "../../../components/ProjectCard.astro";
65
76
import natureLogo from "../../../icons/events/nature/logo-full.png";
87
import type { Project } from "../../../ts/ModGardenAPI";
98
import { getEventProjects } from "../../../ts/ModGardenAPI";
9+
import { formatTime, isoTime } from "../../../ts/TimeHelper";
10+
import { getModrinthProject, type Mod } from "../../../ts/ModrinthHelper";
1011
12+
type ProjectAndMod = {
13+
project: Project;
14+
mod: Mod;
15+
}
1116
12-
const projects: Project[] = await getEventProjects("mod-garden-nature");
13-
projects.sort((a, b) => {
14-
return a.slug.localeCompare(b.slug)
15-
});
17+
async function getProjects() : Promise<ProjectAndMod[]> {
18+
const unsortedProjects = await getEventProjects("mod-garden-nature");
19+
const projects = new Array<ProjectAndMod>(unsortedProjects.length);
20+
for (let i = 0; i < unsortedProjects.length; ++i) {
21+
const project = unsortedProjects[i];
22+
const mod = await getModrinthProject(project.modrinth_id);
23+
projects[i] = { project: project, mod: mod } as ProjectAndMod;
24+
}
25+
projects.sort((a, b) => a.mod.title.localeCompare(b.mod.title))
26+
return projects;
27+
}
28+
29+
const projects: ProjectAndMod[] = await getProjects();
1630
17-
const planningStart = Moment("2025-05-18T00:00:00Z");
18-
const planningEnd = Moment("2025-05-25T00:00:00Z");
19-
const developmentStart = Moment("2025-05-25T00:00:00Z");
20-
const tweakStart = Moment("2025-08-22T00:00:00Z");
21-
const buildStart = Moment("2025-09-05T00:00:00Z");
22-
const buildEnd = Moment("2025-10-01T00:00:00Z");
23-
const showcaseStart = Moment("2025-10-03T00:00:00Z");
24-
const showcaseEnd = Moment("2025-10-10T00:00:00Z");
31+
const planningStart = "2025-05-18T00:00:00Z";
32+
const planningEnd = "2025-05-25T00:00:00Z";
33+
const developmentStart = "2025-05-25T00:00:00Z";
34+
const tweakStart = "2025-08-22T00:00:00Z";
35+
const buildStart = "2025-09-05T00:00:00Z";
36+
const buildEnd = "2025-10-01T00:00:00Z";
37+
const showcaseStart = "2025-10-03T00:00:00Z";
38+
const showcaseEnd = "2025-10-10T00:00:00Z";
2539
---
2640

2741
<Layout title="Mod Garden: Nature" favicon="/images/icon/nature.png" image="/images/icon/nature.png" color="#68ae26">
@@ -119,39 +133,39 @@ const showcaseEnd = Moment("2025-10-10T00:00:00Z");
119133
<ol class="relative border-s border-leaf-600 dark:border-leaf-200">
120134
<li class="mb-[19.5%] ms-4">
121135
<div class="absolute w-3 h-3 bg-pine-500 rounded-full mt-1.5 -start-1.5 dark:bg-pine-700"></div>
122-
<time datetime={planningStart.toISOString()} data-start-time={planningStart} class="mb-1 text-sm font-normal leading-none italic">{planningStart.format("MM/D/YYYY h:mm A")} - {planningEnd.format("MM/D/YYYY h:mm A")}</time>
136+
<time datetime={isoTime(planningStart)} data-start-time={planningStart} class="mb-1 text-sm font-normal leading-none italic">{formatTime(planningStart)} - {formatTime(planningEnd)}time>
123137
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Planning Stage</h3>
124138
<p class="text-base font-normal">
125139
Here you can sign up, and start planning your project. This is the time to start forming teams, planning ideas and general brainstorming.
126140
</p>
127141
</li>
128142
<li class="mb-[19.5%] ms-4">
129143
<div class="absolute w-3 h-3 bg-pine-500 rounded-full mt-1.5 -start-1.5 dark:bg-pine-700"></div>
130-
<time datetime={developmentStart.toISOString()} data-start-time={developmentStart} class="mb-1 text-sm font-normal leading-none italic">{developmentStart.format("MM/D/YYYY h:mm A")} - {tweakStart.format("MM/D/YYYY h:mm A")}</time>
144+
<time datetime={isoTime(developmentStart)} data-start-time={developmentStart} class="mb-1 text-sm font-normal leading-none italic">{formatTime(developmentStart)} - {formatTime(tweakStart)}</time>
131145
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Development Stage</h3>
132146
<p class="text-base font-normal">
133147
This is when you start working on your project(s). You should be submitted to Modrinth at the end of this stage.
134148
</p>
135149
</li>
136150
<li class="mb-[19.5%] ms-4">
137151
<div class="absolute w-3 h-3 bg-pine-500 rounded-full mt-1.5 -start-1.5 dark:bg-pine-700"></div>
138-
<time datetime={tweakStart.toISOString()} data-start-time={tweakStart} class="mb-1 text-sm font-normal leading-none italic">{tweakStart.format("MM/D/YYYY h:mm A")} - {buildStart.format("MM/D/YYYY h:mm A")}</time>
152+
<time datetime={isoTime(tweakStart)} data-start-time={tweakStart} class="mb-1 text-sm font-normal leading-none italic">{formatTime(tweakStart)} - {formatTime(buildStart)}</time>
139153
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Tweak Stage</h3>
140154
<p class="text-base font-normal">
141155
This period is all about fixing bugs, and integrating with other mods to have cross compatibility. Extensions will last until the end of the first week of this phase.
142156
</p>
143157
</li>
144158
<li class="mb-[19.5%] ms-4">
145159
<div class="absolute w-3 h-3 bg-pine-500 rounded-full mt-1.5 -start-1.5 dark:bg-pine-700"></div>
146-
<time datetime={buildStart.toISOString()} data-start-time={buildStart} class="mb-1 text-sm font-normal leading-none italic">{buildStart.format("MM/D/YYYY h:mm A")} - {buildEnd.format("MM/D/YYYY h:mm A")}</time>
160+
<time datetime={isoTime(buildStart)} data-start-time={buildStart} class="mb-1 text-sm font-normal leading-none italic">{formatTime(buildStart)} - {formatTime(buildEnd)}</time>
147161
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Building Stage</h3>
148162
<p class="text-base font-normal">
149163
This stage is optional, but if you want to build a booth for your project, this is the time to do it.
150164
</p>
151165
</li>
152166
<li class="ms-4">
153167
<div class="absolute w-3 h-3 bg-pine-500 rounded-full mt-1.5 -start-1.5 dark:bg-pine-700"></div>
154-
<time datetime={showcaseStart.toISOString()} data-start-time={showcaseStart} class="mb-1 text-sm font-normal leading-none italic">{showcaseStart.format("MM/D/YYYY h:mm A")} - {showcaseEnd.format("MM/D/YYYY h:mm A")}</time>
168+
<time datetime={isoTime(showcaseStart)} data-start-time={showcaseStart} class="mb-1 text-sm font-normal leading-none italic">{formatTime(showcaseStart)} - {formatTime(showcaseEnd)}</time>
155169
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">Showcase Stage</h3>
156170
<p class="text-base font-normal">
157171
This is when the event server is up and running, where you and players can visit booths for all the projects. Players may vote for mods and awards are given in this stage. The server will still be up for some time after this phase ends.
@@ -169,7 +183,8 @@ const showcaseEnd = Moment("2025-10-10T00:00:00Z");
169183
<div class="grid grid-cols-1 gap-2 md:grid-cols-2 lg:grid-cols-3">
170184
{projects.map((project) => (
171185
<ProjectCard
172-
submission={project}
186+
submission={project.project}
187+
mod={project.mod}
173188
showUserInfo={true}
174189
/>
175190
))}

src/ts/TimeHelper.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Moment from "moment";
2+
3+
export const prerender = false;
4+
5+
export async function formatTime(time: string) : Promise<string> {
6+
return Moment(time).format("MM/D/YYYY h:mm A")
7+
}
8+
9+
export function isoTime(time: string) : string {
10+
return Moment(time).toISOString()
11+
}

0 commit comments

Comments
 (0)