Skip to content

Commit 98f439c

Browse files
author
Dimitri POSTOLOV
authoredFeb 19, 2024
export evaluate function for remote content (#2725)
* export `evaluate` function for remote content * fix rust icon on dark mode * prettier * add changelog * update snapshots * update snapshots
1 parent fc9b6f9 commit 98f439c

File tree

9 files changed

+31
-12
lines changed

9 files changed

+31
-12
lines changed
 

Diff for: ‎.changeset/four-beds-smash.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'nextra': patch
3+
---
4+
5+
export `evaluate` function for remote content

Diff for: ‎.changeset/tough-years-sell.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'nextra': patch
3+
---
4+
5+
add rust icon

Diff for: ‎packages/nextra/src/client/components/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export { Code } from './code.js'
55
export { CopyToClipboard } from './copy-to-clipboard.js'
66
export { FileTree } from './file-tree.js'
77
export { Pre } from './pre.js'
8-
export { RemoteContent } from './remote-content.js'
8+
export { RemoteContent, evaluate } from './remote-content.js'
99
export { Steps } from './steps.js'
1010
export { Table } from './table.js'
1111
export { Tabs } from './tabs.js'

Diff for: ‎packages/nextra/src/client/components/pre.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function Pre({
5252
'_border-b-0'
5353
)}
5454
>
55-
{Icon && <Icon className="_h-3.5 _w-auto _shrink-0" />}
55+
{Icon && <Icon className="_h-4 _w-auto _shrink-0" />}
5656
<span className="_truncate">{filename}</span>
5757
{copyButton}
5858
</div>

Diff for: ‎packages/nextra/src/client/components/remote-content.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { jsxRuntime } from '../jsx-runtime.cjs'
33
import type { MDXComponents } from '../mdx.js'
44
import { useMDXComponents } from '../mdx.js'
55

6-
function evaluate(compiledSource: string, scope: Record<string, unknown> = {}) {
6+
export function evaluate(
7+
compiledSource: string,
8+
scope: Record<string, unknown> = {}
9+
) {
710
// if we're ready to render, we can assemble the component tree and let React do its thing
811
// first we set up the scope which has to include the mdx custom
912
// create element function as well as any components we're using

Diff for: ‎packages/nextra/src/client/icons/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export { ReactComponent as CPPIcon } from './c++.svg'
2222
export { ReactComponent as CsharpIcon } from './csharp.svg'
2323
export { ReactComponent as GraphQLIcon } from './graphql.svg'
2424
export { ReactComponent as PythonIcon } from './python.svg'
25-
export { ReactComponent as RustIcon } from './rust.svg';
25+
export { ReactComponent as RustIcon } from './rust.svg'

Diff for: ‎packages/nextra/src/client/icons/rust.svg

+7-7
Loading

Diff for: ‎packages/nextra/src/server/rehype-plugins/__tests__/rehype-icon.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ describe('rehypeIcon', () => {
205205
<_components.span> </_components.span>
206206
</_components.code>
207207
</_components.pre>
208+
{'\\n'}
209+
<_components.pre icon={RustIcon} tabIndex="0" data-language="rs" data-word-wrap="" data-copy="">
210+
<_components.code>
211+
<_components.span> </_components.span>
212+
</_components.code>
213+
</_components.pre>
208214
</>
209215
)
210216
}

Diff for: ‎packages/nextra/src/server/rehype-plugins/rehype-icon.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const REHYPE_ICON_DEFAULT_REPLACES: Record<string, string> = {
2222
python: 'PythonIcon',
2323
py: 'PythonIcon',
2424
rust: 'RustIcon',
25-
rs: 'RustIcon',
25+
rs: 'RustIcon'
2626
}
2727

2828
function createImport(iconName: string) {

0 commit comments

Comments
 (0)
Please sign in to comment.