Skip to content

Commit

Permalink
[v3] fixes for some found issues in the-guild.dev (#3130)
Browse files Browse the repository at this point in the history
a
  • Loading branch information
dimaMachina authored Aug 21, 2024
1 parent 3c6193d commit 799174f
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
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
}
}

0 comments on commit 799174f

Please sign in to comment.