-
Notifications
You must be signed in to change notification settings - Fork 4
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
bac5485
commit a6224f8
Showing
123 changed files
with
3,738 additions
and
2,896 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
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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
packages/fern-docs/bundle/src/app/[[...slug]]/@markdown/page.tsx
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,62 @@ | ||
"use server"; | ||
|
||
import { createCachedFindNode } from "@/app/find-node"; | ||
import { createCachedDocsLoader } from "@/server/cached-docs-loader"; | ||
import { createFileResolver } from "@/server/file-resolver"; | ||
import { withServerProps } from "@/server/withServerProps"; | ||
import { FernNavigation } from "@fern-api/fdr-sdk"; | ||
import { getPageId } from "@fern-api/fdr-sdk/navigation"; | ||
import { | ||
MdxBundlerComponent, | ||
serializeMdx, | ||
} from "@fern-docs/ui/bundlers/mdx-bundler"; | ||
import { notFound } from "next/navigation"; | ||
|
||
export default async function Page({ | ||
params, | ||
}: { | ||
params: Promise<{ slug?: string[] }>; | ||
}) { | ||
const slug = await params.then((params) => | ||
FernNavigation.slugjoin(params.slug) | ||
); | ||
const { domain, host, fern_token } = await withServerProps(); | ||
const findNode = createCachedFindNode(domain, host); | ||
const docs = createCachedDocsLoader(domain, host); | ||
const { node, currentVersion, currentTab, authState } = await findNode( | ||
slug, | ||
fern_token | ||
); | ||
|
||
const pageId = getPageId(node); | ||
if (!pageId) { | ||
return notFound(); | ||
} | ||
|
||
const page = await docs.getPage(pageId); | ||
if (!page) { | ||
return notFound(); | ||
} | ||
|
||
const resolveFileSrc = createFileResolver(await docs.getFiles()); | ||
|
||
const mdx = await serializeMdx(page.markdown, { | ||
filename: pageId, | ||
files: await docs.getMdxBundlerFiles(), | ||
scope: { | ||
props: { | ||
authed: authState.authed, | ||
user: authState.authed ? authState.user : undefined, | ||
version: currentVersion?.versionId, | ||
tab: currentTab?.title, | ||
}, | ||
}, | ||
replaceSrc: resolveFileSrc, | ||
}); | ||
|
||
if (typeof mdx === "string") { | ||
return <div>{mdx}</div>; | ||
} | ||
|
||
return <MdxBundlerComponent {...mdx} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/fern-docs/bundle/src/app/[[...slug]]/global-style.tsx
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 @@ | ||
"use client"; | ||
|
||
export default function GlobalStyle({ children }: { children: string }) { | ||
return ( | ||
<style jsx global> | ||
{children} | ||
</style> | ||
); | ||
} |
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,16 @@ | ||
"use server"; | ||
|
||
export default async function Layout({ | ||
children, | ||
markdown, | ||
}: { | ||
children: React.ReactNode; | ||
markdown: React.ReactNode; | ||
}) { | ||
return ( | ||
<> | ||
{children} | ||
{markdown} | ||
</> | ||
); | ||
} |
Oops, something went wrong.