Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call getMDXComponents() outside HOC_MDXWrapper only 1 time #3611

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ jobs:
- name: Checkout Main
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ jobs:
- name: Checkout Main
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js
uses: actions/setup-node@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
- name: Checkout Main
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js
uses: actions/setup-node@v4
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ jobs:
- name: Checkout Main
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Use Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
Expand Down
2 changes: 1 addition & 1 deletion docs/app/docs/built-ins/head/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ website:

| Hue (H) | Saturation (S) | Lightness (L) | Background Color |
| -------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | ------------------ |
| <Slider max={360} cssVar="--nextra-primary-hue" /> | <Slider max={100} cssVar="--nextra-primary-saturation" /> | <Slider max={100} cssVar='--nextra-primary-lightness' /> | <BackgroundColor/> |
| <Slider max={360} cssVar="--nextra-primary-hue" /> | <Slider max={100} cssVar="--nextra-primary-saturation" /> | <Slider max={100} cssVar="--nextra-primary-lightness" /> | <BackgroundColor/> |

> [!TIP]
>
Expand Down
5 changes: 3 additions & 2 deletions packages/nextra/src/client/setup-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
* This file should be never used directly, only in loader.ts
*/

import { useMDXComponents } from 'next-mdx-import-source-file'
import { useMDXComponents as getMDXComponents } from 'next-mdx-import-source-file'
import type { ComponentProps, FC } from 'react'
import { createElement } from 'react'
import type { Heading, MDXWrapper, PageOpts } from '../types'

const Wrapper = getMDXComponents().wrapper

export function HOC_MDXWrapper(
MDXContent: MDXWrapper,
hocProps: PageOpts & { toc: Heading[] }
): FC<ComponentProps<MDXWrapper>> {
return function MDXWrapper(props) {
const Wrapper = useMDXComponents().wrapper
const children = createElement(MDXContent, props)

return Wrapper ? <Wrapper {...hocProps}>{children}</Wrapper> : children
Expand Down