Skip to content

Commit

Permalink
Keystaticification πŸš€ of docs/ (#9202)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Cousens <413395+dcousens@users.noreply.github.com>
  • Loading branch information
simonswiss and dcousens committed Jul 31, 2024
1 parent fe7e468 commit f07b12f
Show file tree
Hide file tree
Showing 78 changed files with 2,098 additions and 1,305 deletions.
2 changes: 1 addition & 1 deletion docs/app/(site)/blog/[post]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Tag, transform } from '@markdoc/markdoc'
import { notFound } from 'next/navigation'

import { getOgAbsoluteUrl } from '../../../../lib/og-util'
import { reader } from '../../../../lib/keystatic-reader'
import { reader } from '../../../../keystatic/reader'
import { baseMarkdocConfig } from '../../../../markdoc/config'
import { type EntryWithResolvedLinkedFiles } from '@keystatic/core/reader'
import type keystaticConfig from '../../../../keystatic.config'
Expand Down
3 changes: 1 addition & 2 deletions docs/app/(site)/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { parse, format } from 'date-fns'

import { reader } from '../../../lib/keystatic-reader'
import { siteBaseUrl } from '../../../lib/og-util'
import { reader } from '../../../keystatic/reader'
import ClientPage from './page-client'
import { type Metadata } from 'next'

Expand Down
9 changes: 3 additions & 6 deletions docs/app/(site)/docs/[...rest]/page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useParams } from 'next/navigation'
import { type Document } from './page'

import { extractHeadings, Markdoc } from '../../../../components/Markdoc'
import { DocsPage } from '../../../../components/Page'

import { Heading } from '../../../../components/docs/Heading'

export default function PageClient ({ document }: { document: Document }) {
Expand All @@ -17,17 +17,14 @@ export default function PageClient ({ document }: { document: Document }) {
]

return (
<DocsPage
headings={headings}
editPath={`docs/${(params?.rest as string[]).join('/')}.md`}
>
<>
<Heading level={1} id="title">
{document.title}
</Heading>

{document.content.children.map((child, i) => (
<Markdoc key={i} content={child} />
))}
</DocsPage>
</>
)
}
26 changes: 16 additions & 10 deletions docs/app/(site)/docs/[...rest]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { notFound } from 'next/navigation'
import { type Tag, transform } from '@markdoc/markdoc'

import { reader } from '../../../../lib/keystatic-reader'
import { reader } from '../../../../keystatic/reader'
import { baseMarkdocConfig } from '../../../../markdoc/config'
import PageClient from './page-client'
import { type EntryWithResolvedLinkedFiles } from '@keystatic/core/reader'
import type keystaticConfig from '../../../../keystatic.config'
import { DocsLayout } from '../../../../components/docs/DocsLayout'
import { extractHeadings } from '../../../../components/Markdoc'

export type Document = NonNullable<
Pick<
Expand All @@ -22,16 +24,20 @@ export default async function DocPage ({ params }) {
})
if (!doc) return notFound()

const transformedDoc: Document = {
...doc,
content: transform(doc.content.node, baseMarkdocConfig) as Tag,
}

const headings = [
{ id: 'title', depth: 1, label: transformedDoc.title },
// ...extractHeadings(transformedDoc.content),
]

return (
<PageClient
document={JSON.parse(
JSON.stringify({
...doc,
// Prepare content for Markdoc renderer
content: transform(doc.content.node, baseMarkdocConfig),
})
)}
/>
<DocsLayout headings={headings} editPath={`docs/${(params?.rest as string[]).join('/')}.md`}>
<PageClient document={JSON.parse(JSON.stringify(transformedDoc))} />
</DocsLayout>
)
}

Expand Down
10 changes: 2 additions & 8 deletions docs/app/(site)/docs/config/overview/page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
import { CommunitySlackCTA } from '../../../../../components/docs/CommunitySlackCTA'
import { Type } from '../../../../../components/primitives/Type'
import { Well } from '../../../../../components/primitives/Well'
import { DocsPage } from '../../../../../components/Page'
import { useMediaQuery } from '../../../../../lib/media'

export default function Docs () {
const mq = useMediaQuery()

return (
<DocsPage
noRightNav
noProse
isIndexPage
editPath="docs/config/overview.tsx"
>
<>
<Type as="h1" look="heading64">
Configuration Overview
</Type>
Expand Down Expand Up @@ -60,6 +54,6 @@ export default function Docs () {
and one-time authentication tokens.
</Well>
</div>
</DocsPage>
</>
)
}
7 changes: 6 additions & 1 deletion docs/app/(site)/docs/config/overview/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DocsLayout } from '../../../../../components/docs/DocsLayout'
import PageClient from './page-client'

export const metadata = {
Expand All @@ -6,5 +7,9 @@ export const metadata = {
}

export default function Docs () {
return <PageClient />
return (
<DocsLayout noRightNav noProse isIndexPage editPath="docs/config/overview.tsx">
<PageClient />
</DocsLayout>
)
}
Loading

0 comments on commit f07b12f

Please sign in to comment.