Skip to content

Commit

Permalink
fix(navigation): do not nest home page (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed May 30, 2022
1 parent 564b2e8 commit fa702b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/runtime/server/navigation.ts
Expand Up @@ -31,8 +31,10 @@ export function createNav (contents: ParsedContentMeta[], configs: Record<string

// Push index
if (isIndex) {
const indexItem = getNavItem(content)
navItem.children.push(indexItem)
if (content._path !== '/') {
const indexItem = getNavItem(content)
navItem.children.push(indexItem)
}

Object.assign(
navItem,
Expand Down
9 changes: 7 additions & 2 deletions test/features/navigation.ts
Expand Up @@ -6,9 +6,14 @@ import { jsonStringify } from '../../src/runtime/utils/json'
export const testNavigation = () => {
describe('navigation', () => {
test('Get navigation', async () => {
const list = await $fetch('/api/_content/navigation/')

const query = { where: [{ _locale: 'en' }] }
const list = await $fetch(`/api/_content/navigation/${hash(query)}`, {
params: {
_params: jsonStringify(query)
}
})
expect(list.find(item => item._path === '/')).toBeTruthy()
expect(list.find(item => item._path === '/').children).toBeUndefined()
})

test('Get cats navigation', async () => {
Expand Down

0 comments on commit fa702b7

Please sign in to comment.