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(navigation): do not nest home page #1179

Merged
merged 1 commit into from May 30, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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