mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Core: Fix breadcrumb empty when includePage isn't specified
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-core': patch
|
||||
---
|
||||
|
||||
Fix breadcrumb empty when `includePage` isn't specified
|
||||
@@ -89,7 +89,7 @@ function searchPath(
|
||||
const items: BreadcrumbItem[] = [];
|
||||
|
||||
if (separator) items.push({ name: separator });
|
||||
if (options.includePage)
|
||||
if (includePage)
|
||||
items.push({
|
||||
name: node.index.name,
|
||||
url: node.index.url,
|
||||
|
||||
@@ -51,9 +51,7 @@ export function loadFiles(files: VirtualFile[], options: LoadOptions): Storage {
|
||||
}
|
||||
|
||||
if (file.type === 'meta') {
|
||||
storage.write(relativePath, file.type, {
|
||||
data: file.data as MetaData,
|
||||
});
|
||||
storage.write(relativePath, file.type, file.data as MetaData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import {
|
||||
import { describe, expect, test } from 'vitest';
|
||||
import type { Root } from '@/server/page-tree';
|
||||
import { findNeighbour } from '@/server/page-tree-utils';
|
||||
import { PageTree } from '../dist/server';
|
||||
import { getBreadcrumbItems } from '@/breadcrumb';
|
||||
|
||||
test('Find Neighbours', () => {
|
||||
const tree: Root = {
|
||||
@@ -113,3 +115,40 @@ describe('Path utilities', () => {
|
||||
expect(splitPath('/a/c')).toEqual(['a', 'c']);
|
||||
});
|
||||
});
|
||||
|
||||
test('Breadcrumbs', () => {
|
||||
const tree: PageTree.Root = {
|
||||
name: 'Hello World',
|
||||
children: [
|
||||
{
|
||||
type: 'page',
|
||||
name: 'Hello World',
|
||||
url: '/docs',
|
||||
},
|
||||
{
|
||||
type: 'page',
|
||||
name: 'Hello World',
|
||||
url: '/docs/test',
|
||||
},
|
||||
{
|
||||
type: 'page',
|
||||
name: 'Fumadocs',
|
||||
url: '/docs/test2',
|
||||
},
|
||||
{
|
||||
type: 'folder',
|
||||
name: 'Hello World',
|
||||
index: {
|
||||
type: 'page',
|
||||
name: 'World',
|
||||
url: '/docs/folder',
|
||||
},
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(getBreadcrumbItems('/docs/folder', tree)).toStrictEqual([
|
||||
{ name: 'World', url: '/docs/folder' },
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -13,9 +13,7 @@ describe('Virtual Storage', () => {
|
||||
title: 'Hello',
|
||||
},
|
||||
});
|
||||
storage.write('meta.json', 'meta', {
|
||||
data: {},
|
||||
});
|
||||
storage.write('meta.json', 'meta', {});
|
||||
|
||||
expect(storage.list().length).toBe(2);
|
||||
});
|
||||
@@ -26,9 +24,7 @@ describe('Virtual Storage', () => {
|
||||
});
|
||||
|
||||
test('Nested Directories', () => {
|
||||
storage.write('dir1/dir2/meta.json', 'meta', {
|
||||
data: {},
|
||||
});
|
||||
storage.write('dir1/dir2/meta.json', 'meta', {});
|
||||
|
||||
expect(storage.readDir('dir1')).toBeDefined();
|
||||
expect(storage.readDir('dir1/dir2')).toBeDefined();
|
||||
|
||||
Reference in New Issue
Block a user