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

[v3] fixes for some found issues in the-guild.dev #3130

Merged
merged 1 commit into from
Aug 21, 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
7 changes: 7 additions & 0 deletions .changeset/fluffy-pants-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'nextra': patch
---

fixed creating `pageMap` items for folders with dots

remove requirement of passing `filePaths` with `.md`/`.mdx` extensions for `createCatchAllMeta` function
5 changes: 5 additions & 0 deletions .changeset/slow-kings-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nextra-theme-docs': patch
---

fixed react warning `Warning: React has detected a change in the order of Hooks called by Body` when `themeConfig.main` options is used
6 changes: 5 additions & 1 deletion packages/nextra-theme-docs/src/mdx-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ function Body({ children }: { children: ReactNode }): ReactElement {
</>
)

const body = themeConfig.main?.({ children: content }) || content
const body = themeConfig.main ? (
<themeConfig.main>{content}</themeConfig.main>
) : (
content
)

if (themeContext.layout === 'full') {
return (
Expand Down
6 changes: 3 additions & 3 deletions packages/nextra/src/client/catch-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export function createCatchAllMeta(
): DynamicMeta {
const metaMap: DynamicMeta = appendSlashForFolders(customMeta)

const paths = filePaths
.filter(filePath => MARKDOWN_EXTENSION_REGEX.test(filePath))
.map(filePath => filePath.replace(MARKDOWN_EXTENSION_REGEX, '').split('/'))
const paths = filePaths.map(filePath =>
filePath.replace(MARKDOWN_EXTENSION_REGEX, '').split('/')
)

for (const path of paths) {
addToMap(metaMap, path)
Expand Down
5 changes: 3 additions & 2 deletions packages/nextra/src/client/normalize-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ export function normalizePages({
docsDirectories.push(item)
}
}

return {
const result = {
activeType,
activeIndex,
activeThemeContext,
Expand All @@ -422,4 +421,6 @@ export function normalizePages({
flatDocsDirectories,
topLevelNavbarItems
}

return result
}
6 changes: 5 additions & 1 deletion packages/nextra/src/server/page-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ async function collectFiles({
return
}

const fileRoute = normalizePageRoute(route, name)
const fileRoute = normalizePageRoute(
route,
// Directory could have dot, e.g. graphql-eslint-3.14
isDirectory ? name + ext : name
)

if (isDirectory) {
if (fileRoute === '/api') return
Expand Down
4 changes: 3 additions & 1 deletion packages/nextra/src/server/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export async function buildDynamicMDX(
}

export async function buildDynamicMeta(locale = '') {
const pageMap = await globalThis.__nextra_resolvePageMap[locale]()

return {
__nextra_pageMap: await globalThis.__nextra_resolvePageMap[locale]()
__nextra_pageMap: pageMap
}
}