-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v3] show react components, variable interpolation and latex in toc (#…
- Loading branch information
Dimitri POSTOLOV
authored
Sep 29, 2023
1 parent
a6c3119
commit e7e8e84
Showing
19 changed files
with
911 additions
and
400 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,6 @@ | ||
--- | ||
'nextra-theme-docs': major | ||
'nextra': major | ||
--- | ||
|
||
show react components, variable interpolation and latex in toc |
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
179 changes: 93 additions & 86 deletions
179
packages/nextra/__test__/__snapshots__/compile.test.ts.snap
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,127 +1,134 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Process heading > code-h1 1`] = ` | ||
{ | ||
"frontMatter": {}, | ||
"result": "/*@jsxRuntime automatic @jsxImportSource react*/ | ||
import {useMDXComponents as _provideComponents} from \\"nextra/mdx\\"; | ||
"import { useMDXComponents as _provideComponents } from \\"nextra/mdx\\"; | ||
export const frontMatter = {}; | ||
export const toc = []; | ||
function _createMdxContent(props) { | ||
const _components = Object.assign({ | ||
h1: \\"h1\\", | ||
code: \\"code\\" | ||
}, _provideComponents(), props.components); | ||
return <_components.h1><_components.code>{\\"codegen.yml\\"}</_components.code></_components.h1>; | ||
} | ||
function MDXContent(props = {}) { | ||
const {wrapper: MDXLayout} = Object.assign({}, _provideComponents(), props.components); | ||
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout> : _createMdxContent(props); | ||
export function useTOC(props) { | ||
return []; | ||
} | ||
export default MDXContent; | ||
", | ||
"title": "codegen.yml", | ||
function _createMdxContent(props) { | ||
const { toc } = props; | ||
const _components = Object.assign( | ||
{ | ||
h1: \\"h1\\", | ||
code: \\"code\\", | ||
}, | ||
_provideComponents(), | ||
props.components, | ||
); | ||
return ( | ||
<_components.h1> | ||
<_components.code>{\\"codegen.yml\\"}</_components.code> | ||
</_components.h1> | ||
); | ||
} | ||
" | ||
`; | ||
|
||
exports[`Process heading > code-with-text-h1 1`] = ` | ||
{ | ||
"frontMatter": {}, | ||
"result": "/*@jsxRuntime automatic @jsxImportSource react*/ | ||
import {useMDXComponents as _provideComponents} from \\"nextra/mdx\\"; | ||
"import { useMDXComponents as _provideComponents } from \\"nextra/mdx\\"; | ||
export const frontMatter = {}; | ||
export const toc = []; | ||
function _createMdxContent(props) { | ||
const _components = Object.assign({ | ||
h1: \\"h1\\", | ||
code: \\"code\\" | ||
}, _provideComponents(), props.components); | ||
return <_components.h1><_components.code>{\\"codegen.yml\\"}</_components.code>{\\" file\\"}</_components.h1>; | ||
} | ||
function MDXContent(props = {}) { | ||
const {wrapper: MDXLayout} = Object.assign({}, _provideComponents(), props.components); | ||
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout> : _createMdxContent(props); | ||
export function useTOC(props) { | ||
return []; | ||
} | ||
export default MDXContent; | ||
", | ||
"title": "codegen.yml file", | ||
function _createMdxContent(props) { | ||
const { toc } = props; | ||
const _components = Object.assign( | ||
{ | ||
h1: \\"h1\\", | ||
code: \\"code\\", | ||
}, | ||
_provideComponents(), | ||
props.components, | ||
); | ||
return ( | ||
<_components.h1> | ||
<_components.code>{\\"codegen.yml\\"}</_components.code> | ||
{\\" file\\"} | ||
</_components.h1> | ||
); | ||
} | ||
" | ||
`; | ||
|
||
exports[`Process heading > dynamic-h1 1`] = ` | ||
{ | ||
"frontMatter": {}, | ||
"hasJsxInH1": true, | ||
"result": "/*@jsxRuntime automatic @jsxImportSource react*/ | ||
import {useMDXComponents as _provideComponents} from \\"nextra/mdx\\"; | ||
"result": "import { useMDXComponents as _provideComponents } from \\"nextra/mdx\\"; | ||
export const frontMatter = {}; | ||
import {useRouter} from 'next/router'; | ||
import { useRouter } from \\"next/router\\"; | ||
export const TagName = () => { | ||
const {tag} = useRouter().query; | ||
const { tag } = useRouter().query; | ||
return tag || null; | ||
}; | ||
export const toc = []; | ||
function _createMdxContent(props) { | ||
const _components = Object.assign({ | ||
h1: \\"h1\\" | ||
}, _provideComponents(), props.components); | ||
return <_components.h1>{\\"Posts Tagged with “\\"}<TagName />{\\"”\\"}</_components.h1>; | ||
export function useTOC(props) { | ||
return []; | ||
} | ||
function MDXContent(props = {}) { | ||
const {wrapper: MDXLayout} = Object.assign({}, _provideComponents(), props.components); | ||
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout> : _createMdxContent(props); | ||
function _createMdxContent(props) { | ||
const { toc } = props; | ||
const _components = Object.assign( | ||
{ | ||
h1: \\"h1\\", | ||
}, | ||
_provideComponents(), | ||
props.components, | ||
); | ||
return ( | ||
<_components.h1> | ||
{\\"Posts Tagged with “\\"} | ||
<TagName /> | ||
{\\"”\\"} | ||
</_components.h1> | ||
); | ||
} | ||
export default MDXContent; | ||
", | ||
"title": "Posts Tagged with “”", | ||
} | ||
`; | ||
|
||
exports[`Process heading > no-h1 1`] = ` | ||
{ | ||
"frontMatter": {}, | ||
"result": "/*@jsxRuntime automatic @jsxImportSource react*/ | ||
import {useMDXComponents as _provideComponents} from \\"nextra/mdx\\"; | ||
"import { useMDXComponents as _provideComponents } from \\"nextra/mdx\\"; | ||
export const frontMatter = {}; | ||
export const toc = [{ | ||
depth: 2, | ||
value: \\"H2\\", | ||
id: \\"h2\\" | ||
}]; | ||
function _createMdxContent(props) { | ||
const _components = Object.assign({ | ||
h2: \\"h2\\" | ||
}, _provideComponents(), props.components); | ||
return <_components.h2 id=\\"h2\\">{\\"H2\\"}</_components.h2>; | ||
export function useTOC(props) { | ||
return [ | ||
{ | ||
value: \\"H2\\", | ||
id: \\"h2\\", | ||
depth: 2, | ||
}, | ||
]; | ||
} | ||
function MDXContent(props = {}) { | ||
const {wrapper: MDXLayout} = Object.assign({}, _provideComponents(), props.components); | ||
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout> : _createMdxContent(props); | ||
} | ||
export default MDXContent; | ||
", | ||
function _createMdxContent(props) { | ||
const { toc } = props; | ||
const _components = Object.assign( | ||
{ | ||
h2: \\"h2\\", | ||
}, | ||
_provideComponents(), | ||
props.components, | ||
); | ||
return <_components.h2 id={toc[0].id}>{toc[0].value}</_components.h2>; | ||
} | ||
" | ||
`; | ||
|
||
exports[`Process heading > static-h1 1`] = ` | ||
{ | ||
"frontMatter": {}, | ||
"result": "/*@jsxRuntime automatic @jsxImportSource react*/ | ||
import {useMDXComponents as _provideComponents} from \\"nextra/mdx\\"; | ||
"import { useMDXComponents as _provideComponents } from \\"nextra/mdx\\"; | ||
export const frontMatter = {}; | ||
export const toc = []; | ||
export function useTOC(props) { | ||
return []; | ||
} | ||
function _createMdxContent(props) { | ||
const _components = Object.assign({ | ||
h1: \\"h1\\" | ||
}, _provideComponents(), props.components); | ||
const { toc } = props; | ||
const _components = Object.assign( | ||
{ | ||
h1: \\"h1\\", | ||
}, | ||
_provideComponents(), | ||
props.components, | ||
); | ||
return <_components.h1>{\\"Hello World\\"}</_components.h1>; | ||
} | ||
function MDXContent(props = {}) { | ||
const {wrapper: MDXLayout} = Object.assign({}, _provideComponents(), props.components); | ||
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props} /></MDXLayout> : _createMdxContent(props); | ||
} | ||
export default MDXContent; | ||
", | ||
"title": "Hello World", | ||
} | ||
" | ||
`; |
Oops, something went wrong.