Skip to content

Commit

Permalink
prep for golink
Browse files Browse the repository at this point in the history
  • Loading branch information
dinoDanic committed Mar 2, 2024
1 parent 5acd13e commit e520449
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 5 deletions.
3 changes: 3 additions & 0 deletions apps/bible/app/bible/project-structure/module/exmaple.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

- everything should be exported from index.tsx

# bad
<todo. ... /> no cmp

# module/todo/index.tsx

```
Expand Down
38 changes: 38 additions & 0 deletions apps/bible/app/bible/routing/nested-dynamic-routes/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Stack } from "@/components/primitives/stack";
import { Text } from "@/components/typography/text";
import { routes } from "@/site/routes";
import Link from "next/link";
import { FC, PropsWithChildren } from "react";

const NestedDynamicRoutesPage = () => {
return (
<Stack>
<Layout title="Autocomplete / typesefe">
<Link href="/bible/routing/nested-dynamic-routes/todo/1">Todo #1</Link>
</Layout>
<Layout title="Continue route - works, bug">
{/*@ts-ignore*/}
<Link href="nested-dynamic-routes/todo/1">Todo #1</Link>
</Layout>
<Layout title="function / typesafe">
<Link
href={routes.bible.routing.nestedDynamicRoutes.todo[":id"]("2").index}
>
Todo #1
</Link>
</Layout>
</Stack>
);
};

const Layout: FC<{ title: string } & PropsWithChildren> = ({
title,
children,
}) => (
<Stack gap="xs">
<Text>{title}</Text>
{children}
</Stack>
);

export default NestedDynamicRoutesPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const TodoPageById = () => {
return <div>todo page by id</div>;
};

export default TodoPageById;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const UserPageById = () => {
return <div>user page by id</div>;
};

export default UserPageById;
1 change: 0 additions & 1 deletion apps/bible/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default function RootLayout(
children: React.ReactNode;
}>,
) {
console.log(props);
return (
<html lang="en">
<body className={cn(inter.className, "p-sm")}>
Expand Down
4 changes: 4 additions & 0 deletions apps/bible/site/bible-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const bibleContents: BibleContent[] = [
title: "Intercepting Routes",
href: routes.bible.routing.interceptingRoutes.index,
},
{
title: "Nested dynamic routes",
href: routes.bible.routing.nestedDynamicRoutes.index,
},
],
},
{
Expand Down
34 changes: 30 additions & 4 deletions apps/bible/site/routes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Route } from "next";

export const routes = {
todos: {
index: "/todos",
Expand All @@ -8,15 +10,39 @@ export const routes = {
index: "/bible/data-fetching/parrallel-and-sequential",
},
},
projectStructure: {
module: {
index: "/bible/project-structure/module",
},
},
routing: {
interceptingRoutes: {
index: "/bible/routing/intercepting-routes",
},
},
projectStructure: {
module: {
index: "/bible/project-structure/module",
nestedDynamicRoutes: {
index: "/bible/routing/nested-dynamic-routes",
todo2: {
":id": {
index: "/bible/routing/nested-dynamic-routes/todo/:id",
},
},
todo: {
":id": (id: string): Record<string, Route> => ({
// @ts-ignore
index: `/bible/routing/nested-dynamic-routes/todo/${id}`,
}),
},
},
},
},
} as const;

type GoToArgs = {
where: "";
};

type GoTo = (args: GoToArgs) => Route;

export const goTo: GoTo = (args) => {
return "/bible/data-fetching/parrallel-and-sequential";
};

0 comments on commit e520449

Please sign in to comment.