Skip to content

Commit

Permalink
Remove unecessary unstable_defineLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Jul 22, 2024
1 parent 7249f25 commit 4fd3fb0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
7 changes: 3 additions & 4 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { unstable_defineLoader } from "@remix-run/node";
import type { MetaFunction } from "@remix-run/react";
import { useLoaderData } from "@remix-run/react";

Expand All @@ -8,7 +7,7 @@ import { constructSiteTitle } from "~/utils/common";

import eventsJson from "../data/events.json";

export const loader = unstable_defineLoader(() => {
export function loader() {
// This assumes the events are always in sorted order, newest first.
// Surely this assumption on undocumented data behavior will never come back to haunt us.
const events = eventsJson.map((event) => ({
Expand All @@ -27,7 +26,7 @@ export const loader = unstable_defineLoader(() => {
return events
.filter(({ date }) => date > now && date < sixWeeksInTheFuture)
.sort((a, b) => a.date.getTime() - b.date.getTime());
});
}

export const meta: MetaFunction = () => {
return [{ title: constructSiteTitle() }];
Expand All @@ -46,7 +45,7 @@ export default function Index() {
</h2>
{events.map((event, index) => (
<EventDetails
date={new Date(event.date)}
date={event.date}
key={index}
link={event.link}
linkText="Register Now"
Expand Down
5 changes: 3 additions & 2 deletions app/routes/about.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { unstable_defineLoader } from "@remix-run/node";
import { type MetaFunction, useLoaderData } from "@remix-run/react";

import { PageGrid } from "~/components/PageGrid";
Expand All @@ -10,7 +9,9 @@ export const meta: MetaFunction = () => {
return [{ title: constructSiteTitle("About") }];
};

export const loader = unstable_defineLoader(() => team);
export function loader() {
return team;
}

export default function About() {
const data = useLoaderData<typeof loader>();
Expand Down
6 changes: 3 additions & 3 deletions app/routes/events.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { unstable_defineLoader } from "@remix-run/node";
import type { MetaFunction } from "@remix-run/react";
import { useLoaderData } from "@remix-run/react";

Expand All @@ -10,16 +9,17 @@ import { constructSiteTitle, groupBy } from "~/utils/common";

import events from "../data/events.json";

export const loader = unstable_defineLoader(() => {
export function loader() {
return groupBy(events, (event) => new Date(event.date).getFullYear());
});
}

export const meta: MetaFunction = () => {
return [{ title: constructSiteTitle("Events") }];
};

export default function Events() {
const data = useLoaderData<typeof loader>();
console.log(data);

return (
<PageGrid
Expand Down
5 changes: 2 additions & 3 deletions app/routes/ics-feed[.ics].ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { unstable_defineLoader } from "@remix-run/node";
import type { DurationObject, EventAttributes } from "ics";
import icsService from "ics-service";

import { site } from "~/config";

import eventJson from "../data/events.json";

export const loader = unstable_defineLoader(() => {
export function loader() {
const eventData = [...eventJson].reverse();
const events: EventAttributes[] = eventData.map((event, index) => {
const date = new Date(event.date);
Expand Down Expand Up @@ -42,4 +41,4 @@ export const loader = unstable_defineLoader(() => {
"Content-Disposition": `attachment; filename="phillyjs.ics"`,
},
});
});
}
5 changes: 3 additions & 2 deletions app/routes/join-us.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { unstable_defineLoader } from "@remix-run/node";
import { type MetaFunction, useLoaderData } from "@remix-run/react";

import { Icons } from "~/components/Icons";
Expand All @@ -7,7 +6,9 @@ import { constructSiteTitle } from "~/utils/common";

import platforms from "../data/platforms.json";

export const loader = unstable_defineLoader(() => platforms);
export function loader() {
return platforms;
}

export const meta: MetaFunction = () => {
return [{ title: constructSiteTitle("Join Us") }];
Expand Down
5 changes: 3 additions & 2 deletions app/routes/sponsors.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { unstable_defineLoader } from "@remix-run/node";
import { type MetaFunction, useLoaderData } from "@remix-run/react";

import { Icons } from "~/components/Icons";
Expand All @@ -7,7 +6,9 @@ import { constructSiteTitle } from "~/utils/common";

import sponsors from "../data/sponsors.json";

export const loader = unstable_defineLoader(() => sponsors);
export function loader() {
return sponsors;
}

export const meta: MetaFunction = () => {
return [{ title: constructSiteTitle("Sponsors") }];
Expand Down

0 comments on commit 4fd3fb0

Please sign in to comment.