-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c28152
commit ede3db8
Showing
10 changed files
with
125 additions
and
42 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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
output: "export", | ||
experimental: { mdxRs: true }, | ||
images: { unoptimized: true }, | ||
webpack: (config) => { | ||
config.module.rules.push({ | ||
test: /\.woff2$/, | ||
type: "asset/resource", | ||
}) | ||
return config | ||
}, | ||
images: { | ||
unoptimized: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig | ||
const withMDX = require("@next/mdx")() | ||
module.exports = withMDX(nextConfig) |
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,12 @@ | ||
import fs from "fs" | ||
import path from "path" | ||
|
||
export default function getLocalContent(id: string) { | ||
const filePath = path.join(process.cwd(), `src/content/startups/${id}.mdx`) | ||
|
||
if (fs.existsSync(filePath)) { | ||
return fs.readFileSync(filePath, "utf8") | ||
} | ||
|
||
return null | ||
} |
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,18 @@ | ||
import MDXComponent from "@/utils/mdx-component" | ||
import getLocalContent from "./get-local-content" | ||
|
||
export default function LocalContent({ id }: { id: string }) { | ||
const markdown = getLocalContent(id) | ||
|
||
return ( | ||
<> | ||
{markdown ? ( | ||
<div className="fr-py-6w"> | ||
<div className="fr-container"> | ||
<MDXComponent markdown={markdown} /> | ||
</div> | ||
</div> | ||
) : null} | ||
</> | ||
) | ||
} |
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,21 @@ | ||
import { remark } from "remark" | ||
|
||
import MDXComponent from "@/utils/mdx-component" | ||
|
||
export default async function RemoteContent({ | ||
content_url_encoded_markdown, | ||
}: { | ||
content_url_encoded_markdown: string | ||
}) { | ||
const markdown = await remark().process( | ||
decodeURIComponent(content_url_encoded_markdown) | ||
) | ||
|
||
return ( | ||
<div className="fr-py-6w"> | ||
<div className="fr-container"> | ||
<MDXComponent markdown={markdown} /> | ||
</div> | ||
</div> | ||
) | ||
} |
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,3 @@ | ||
## Contenu local | ||
|
||
Je suis une description du code du travail numérique chargée à la volée ! |
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,15 @@ | ||
import type { MDXComponents } from "mdx/types" | ||
|
||
// This file allows you to provide custom React components | ||
// to be used in MDX files. You can import and use any | ||
// React component you want, including components from | ||
// other libraries. | ||
|
||
// This file is required to use MDX in `app` directory. | ||
export function useMDXComponents(components: MDXComponents): MDXComponents { | ||
return { | ||
// Allows customizing built-in components, e.g. to add styling. | ||
// h1: ({ children }) => <h1 style={{ fontSize: "100px" }}>{children}</h1>, | ||
...components, | ||
} | ||
} |
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,35 @@ | ||
import { MDXRemote } from "next-mdx-remote/rsc" | ||
|
||
import type { VFile } from "vfile" | ||
import type { MDXComponents } from "mdx/types" | ||
|
||
export default function MDXComponent({ | ||
markdown, | ||
}: { | ||
markdown: string | VFile | ||
}) { | ||
const component = { | ||
h1: ({ children }: { children: React.ReactNode }) => ( | ||
<h1 className="fr-h1">{children}</h1> | ||
), | ||
h2: ({ children }: { children: React.ReactNode }) => ( | ||
<h2 className="fr-h2">{children}</h2> | ||
), | ||
h3: ({ children }: { children: React.ReactNode }) => ( | ||
<h2 className="fr-h3">{children}</h2> | ||
), | ||
p: ({ children }: { children: React.ReactNode }) => ( | ||
<p className="mb-6">{children}</p> | ||
), | ||
ul: ({ children }: { children: React.ReactNode }) => ( | ||
<ul className="mb-6">{children}</ul> | ||
), | ||
a: ({ children, ...props }: { children: React.ReactNode }) => ( | ||
<a {...props} target="_blank" rel="noopener"> | ||
{children} | ||
</a> | ||
), | ||
} as MDXComponents | ||
|
||
return <MDXRemote source={markdown} components={component} /> | ||
} |
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 |
---|---|---|
|
@@ -152,6 +152,13 @@ | |
dependencies: | ||
glob "7.1.7" | ||
|
||
"@next/[email protected]": | ||
version "13.4.13" | ||
resolved "https://registry.yarnpkg.com/@next/mdx/-/mdx-13.4.13.tgz#e2e4d73c4d00cd9ced8f4c47805d8a3784e36c18" | ||
integrity sha512-rQHfeyPO6WC+mEqFCNibV8CWXBJ95uRfPv05Xb8ZMUr284grCIAaSfSRDDrwcoknizyfREDp33oV/isIujS4pA== | ||
dependencies: | ||
source-map "^0.7.0" | ||
|
||
"@next/[email protected]": | ||
version "13.4.12" | ||
resolved "https://registry.yarnpkg.com/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.4.12.tgz#326c830b111de8a1a51ac0cbc3bcb157c4c4f92c" | ||
|