-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Francis Thibault <francis.thibault@gmail.com>
- Loading branch information
Showing
42 changed files
with
696 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { notFound } from "next/navigation"; | ||
import { allComponents } from "@/.contentlayer/generated"; | ||
import { Mdx } from "@/components/Mdx/MdxComponent"; | ||
|
||
interface PageProps { | ||
params: { | ||
slug: string; | ||
}; | ||
} | ||
|
||
async function getNoteFromParams(params: PageProps["params"]) { | ||
const note = allComponents.find(component => component.slug === params.slug); | ||
|
||
if (!note) { | ||
return null; | ||
} | ||
|
||
return note; | ||
} | ||
|
||
export async function generateStaticParams(): Promise<PageProps["params"][]> { | ||
return allComponents.map(({ slug }) => ({ | ||
slug | ||
})); | ||
} | ||
|
||
export default async function Note({ params }: PageProps) { | ||
const note = await getNoteFromParams(params); | ||
|
||
if (!note) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<main> | ||
<article key={note._id}> | ||
{note.status && | ||
`status: ${note.status}` | ||
} | ||
{note.body && <Mdx code={note.body.code} />} | ||
</article> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function Custom404() { | ||
return ( | ||
<main> | ||
<article> | ||
<h1>404 - Page Not Found</h1> | ||
</article> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { notFound } from "next/navigation"; | ||
import { allTokens } from "@/.contentlayer/generated"; | ||
import { Mdx } from "@/components/Mdx/MdxComponent"; | ||
|
||
interface PageProps { | ||
params: { | ||
slug: string; | ||
section: string; | ||
}; | ||
} | ||
|
||
async function getNoteFromParams(params: PageProps["params"]) { | ||
const note = allTokens.find(token => token.slug === params.slug && token.section === params.section); | ||
|
||
if (!note) { | ||
return null; | ||
} | ||
|
||
return note; | ||
} | ||
|
||
export async function generateStaticParams(): Promise<PageProps["params"][]> { | ||
return allTokens.map(({ slug, section }) => ({ | ||
slug, | ||
section | ||
})); | ||
} | ||
|
||
export default async function Note({ params }: PageProps) { | ||
const note = await getNoteFromParams(params); | ||
|
||
if (!note) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<main> | ||
<article key={note._id}> | ||
{note.body && <Mdx code={note.body.code} />} | ||
</article> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import React from "react"; | ||
import "./aside.css"; | ||
|
||
interface Link { | ||
title: string; | ||
url: string; | ||
} | ||
|
||
interface AsideProps { | ||
title: string; | ||
links: Link[]; | ||
} | ||
|
||
export const Aside: React.FC<AsideProps> = ({ title, links }) => { | ||
return ( | ||
<aside className="hd-aside"> | ||
<ul className="hd-aside__list"> | ||
<li className="hd-aside__item hd-aside-section"> | ||
<span className="hd-aside__title">{title}</span> | ||
<ul className="hd-aside__nested-list"> | ||
{links.map(link => ( | ||
<li className="hd-aside__item"> | ||
<Link href={link.url} key={link.title} className="hd-aside__link"> | ||
{link.title} | ||
</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</li> | ||
</ul> | ||
</aside> | ||
); | ||
}; |
Oops, something went wrong.