Skip to content

Commit

Permalink
fix regression from Nextra 3 setting theme.collapsed?: boolean in `…
Browse files Browse the repository at this point in the history
…_meta` file for folders has no effect in sidebar (#4062)

* a

* fix
  • Loading branch information
dimaMachina authored Jan 26, 2025
1 parent 20f7aaa commit 29a44de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/giant-garlics-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"nextra": patch
"nextra-theme-blog": patch
"nextra-theme-docs": patch
---

fix regression from Nextra 3 setting [`theme.collapsed?: boolean` in `_meta` file](https://nextra.site/docs/file-conventions/meta-file#theme-option) for folders has no effect in sidebar
4 changes: 2 additions & 2 deletions docs/app/docs/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ project. If you have a question that isn't answered here, please

<details>
<summary className="mb-2">Can I use X with Nextra?</summary>
The answer is "yes" for most things. Since Nextra is just a Next.js plugin, almost all the things
that can be done with React can be done with Nextra. Here are some examples and guides:
The answer is "yes" for most things. Since Nextra is just a Next.js plugin, almost all the things
that can be done with React can be done with Nextra. Here are some examples and guides:

- [Use Tailwind CSS](/docs/guide/tailwind-css)
- [Use custom CSS and Sass](/docs/guide/custom-css)
Expand Down
9 changes: 8 additions & 1 deletion packages/nextra/src/client/normalize-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Folder, FrontMatter, MdxFile, PageMapItem } from '../types.js'

const DEFAULT_PAGE_THEME: PageTheme = {
breadcrumb: true,
collapsed: false,
collapsed: undefined,
footer: true,
layout: 'default',
navbar: true,
Expand Down Expand Up @@ -177,6 +177,13 @@ export function normalizePages({
})
const item: Item = getItem()
const docsItem: DocsItem = getItem()
if ('children' in docsItem) {
const { collapsed } = extendedMeta.theme
if (typeof collapsed === 'boolean') {
// @ts-expect-error -- fixme
docsItem.theme = { collapsed }
}
}
const pageItem: PageItem = getItem()

docsItem.isUnderCurrentDocsTree = underCurrentDocsRoot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ exports[`normalize-page > en-US getting-started 1`] = `
],
"activeThemeContext": {
"breadcrumb": true,
"collapsed": false,
"collapsed": undefined,
"footer": true,
"layout": "default",
"navbar": true,
Expand Down Expand Up @@ -838,7 +838,7 @@ exports[`normalize-page > en-US home 1`] = `
],
"activeThemeContext": {
"breadcrumb": true,
"collapsed": false,
"collapsed": undefined,
"footer": true,
"layout": "default",
"navbar": true,
Expand Down Expand Up @@ -1520,7 +1520,7 @@ exports[`normalize-page > should keep \`activeThemeContext\`, \`activeType\` for
"activePath": [],
"activeThemeContext": {
"breadcrumb": true,
"collapsed": false,
"collapsed": undefined,
"footer": true,
"layout": "full",
"navbar": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra/src/server/__tests__/normalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('normalize-page', () => {
activeIndex: 0,
activeThemeContext: {
breadcrumb: true,
collapsed: false,
collapsed: undefined,
footer: true,
layout: 'default',
navbar: true,
Expand Down

0 comments on commit 29a44de

Please sign in to comment.