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

fix regression from Nextra 3 setting theme.collapsed?: boolean in _meta file for folders has no effect in sidebar #4062

Merged
merged 2 commits into from
Jan 26, 2025
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/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
Loading