Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧑‍💻 RFC: Add typed routes using routes-gen #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
useCatch,
} from "@remix-run/react";

import { route } from "routes-gen";

import { Todo } from "./components/todo";
import globalStyles from "./global.css";
import tailwindStyles from "./tailwind.css";
Expand Down Expand Up @@ -98,14 +100,14 @@ interface MenuItem {
href: string;
}
const MENU_ITEMS: MenuItem[] = [
{ title: "Dette kan vi", href: "/dette-kan-vi" },
{ title: "Dette har vi gjort", href: "/dette-har-vi-gjort" },
{ title: "Blogg", href: "/blogg" },
{ title: "Mentorprogram", href: "/mentor" },
{ title: "Bli en av oss", href: "/bli-en-av-oss" },
{ title: "Partnere", href: "/partnere" },
{ title: "Om oss", href: "/om-oss" },
{ title: "Ansatte", href: "/ansatte" },
{ title: "Dette kan vi", href: route("/dette-kan-vi") },
{ title: "Dette har vi gjort", href: route("/dette-har-vi-gjort") },
{ title: "Blogg", href: route("/blogg") },
{ title: "Mentorprogram", href: route("/mentor") },
{ title: "Bli en av oss", href: route("/bli-en-av-oss") },
{ title: "Partnere", href: route("/partnere") },
{ title: "Om oss", href: route("/om-oss") },
{ title: "Ansatte", href: route("/ansatte") },
];
const Header = () => {
return (
Expand All @@ -115,7 +117,7 @@ const Header = () => {
className="border-l-0 border-r-0 border-t-0 border-b-2 h-20 w-full"
>
<div className="flex w-screen gap-2 justify-between items-center px-4">
<a href="/" className="text-2xl font-bold">
<a href={route("/")} className="text-2xl font-bold">
CAPRA
</a>
<ul className="flex items-center overflow-scroll">
Expand Down
42 changes: 42 additions & 0 deletions app/routes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
declare module "routes-gen" {
export type RouteParams = {
"/dette-kan-vi/it-konsulenter": {};
"/dette-har-vi-gjort/:slug": { slug: string };
"/dette-har-vi-gjort": {};
"/personvernerklaering": {};
"/dette-kan-vi/liflig": {};
"/informasjonskapsler": {};
"/dette-kan-vi": {};
"/test/hello-sanity": {};
"/test/kitchen-sink": {};
"/bli-en-av-oss": {};
"/blogg/:slug": { slug: string };
"/blogg": {};
"/partnere": {};
"/ansatte": {};
"/mentor": {};
"/om-oss": {};
"/": {};
};

export function route<
T extends
| ["/dette-kan-vi/it-konsulenter"]
| ["/dette-har-vi-gjort/:slug", RouteParams["/dette-har-vi-gjort/:slug"]]
| ["/dette-har-vi-gjort"]
| ["/personvernerklaering"]
| ["/dette-kan-vi/liflig"]
| ["/informasjonskapsler"]
| ["/dette-kan-vi"]
| ["/test/hello-sanity"]
| ["/test/kitchen-sink"]
| ["/bli-en-av-oss"]
| ["/blogg/:slug", RouteParams["/blogg/:slug"]]
| ["/blogg"]
| ["/partnere"]
| ["/ansatte"]
| ["/mentor"]
| ["/om-oss"]
| ["/"],
>(...args: T): typeof args[0];
}
Loading