Skip to content

Commit

Permalink
fix inconsistent font-weight: bold style for type: 'menu' (#1889)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed May 22, 2023
1 parent a216eb6 commit 15c4092
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/selfish-news-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'nextra': patch
'nextra-theme-docs': patch
---

fix inconsistent `font-weight: bold` style for `type: 'menu'`
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PageMapItem } from 'nextra'
import type { PageMapItem } from '../../../src/types'

export const cnPageMap: PageMapItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest'
import { cnPageMap, usPageMap } from './__fixture__/pageMap'
import { normalizePages } from 'nextra/normalize-pages'
import { cnPageMap, usPageMap } from './fixture/page-maps/pageMap'
import { normalizePages } from '../src/normalize-pages'

const defaultLocale = 'en-US'

Expand Down Expand Up @@ -110,4 +110,100 @@ describe('normalize-page', () => {
})
expect(result).toMatchSnapshot()
})

// https://github.com/shuding/nextra/issues/1888
it('should set `route: #` for `type: menu`', () => {
const result = normalizePages({
list: [
{
kind: 'Meta',
data: {
index: {
type: 'page',
title: 'Nextra',
display: 'hidden'
},
docs: {
type: 'page',
title: 'Documentation'
},
explorers: {
title: 'Explorers',
type: 'menu'
},
showcase: {
type: 'page',
title: 'Showcase'
},
explorers2: {
title: 'Explorers2',
type: 'menu'
},
about: {
type: 'page',
title: 'About'
},
explorers3: {
title: 'Explorers3',
type: 'menu'
}
}
},
{
kind: 'MdxPage',
name: 'about',
route: '/about'
},
{
kind: 'MdxPage',
name: 'showcase',
route: '/showcase'
}
],
locale: 'en-US',
route: '/docs'
})
expect(result.topLevelNavbarItems).toMatchInlineSnapshot(`
[
{
"name": "docs",
"route": "#",
"title": "Documentation",
"type": "page",
},
{
"name": "explorers",
"route": "#",
"title": "Explorers",
"type": "menu",
},
{
"kind": "MdxPage",
"name": "showcase",
"route": "/showcase",
"title": "Showcase",
"type": "page",
},
{
"name": "explorers2",
"route": "#",
"title": "Explorers2",
"type": "menu",
},
{
"kind": "MdxPage",
"name": "about",
"route": "/about",
"title": "About",
"type": "page",
},
{
"name": "explorers3",
"route": "#",
"title": "Explorers3",
"type": "menu",
},
]
`)
})
})
2 changes: 1 addition & 1 deletion packages/nextra/src/normalize-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export function normalizePages({
if (key !== '*') {
items.push({
name: key,
route: '',
route: '#',
...meta[key]
})
}
Expand Down

1 comment on commit 15c4092

@vercel
Copy link

@vercel vercel bot commented on 15c4092 May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.