fumadocs-core 16.17.3 → 16.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { r as findPath } from "./utils-DEVq3cEC.js";
|
|
2
1
|
import { r as extname, t as basename } from "./path-m9Srg2Jq.js";
|
|
3
2
|
//#region src/search/server/build-index.ts
|
|
4
3
|
async function buildIndexDefault(page) {
|
|
@@ -29,19 +28,27 @@ async function buildDocuments(source, map) {
|
|
|
29
28
|
function isBreadcrumbItem(item) {
|
|
30
29
|
return typeof item === "string" && item.length > 0;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Get the breadcrumbs of pages, each page tree is walked once.
|
|
33
|
+
*/
|
|
34
|
+
function createBreadcrumbs(source) {
|
|
35
|
+
const trees = /* @__PURE__ */ new Map();
|
|
36
|
+
return (page) => {
|
|
37
|
+
const tree = source.getPageTree(page.locale);
|
|
38
|
+
let breadcrumbs = trees.get(tree);
|
|
39
|
+
if (!breadcrumbs) trees.set(tree, breadcrumbs = collectBreadcrumbs(tree, [], /* @__PURE__ */ new Map()));
|
|
40
|
+
return breadcrumbs.get(page.url);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** like `findPath()`, a page takes its first path, with the separator above it */
|
|
44
|
+
function collectBreadcrumbs(folder, parents, out) {
|
|
45
|
+
const path = isBreadcrumbItem(folder.name) ? [...parents, folder.name] : parents;
|
|
46
|
+
if (folder.type === "folder" && folder.index && !out.has(folder.index.url)) out.set(folder.index.url, path);
|
|
47
|
+
let current = path;
|
|
48
|
+
for (const node of folder.children) if (node.type === "separator") current = isBreadcrumbItem(node.name) ? [...path, node.name] : path;
|
|
49
|
+
else if (node.type === "folder") collectBreadcrumbs(node, current, out);
|
|
50
|
+
else if (!out.has(node.url)) out.set(node.url, current);
|
|
51
|
+
return out;
|
|
45
52
|
}
|
|
46
53
|
//#endregion
|
|
47
|
-
export {
|
|
54
|
+
export { buildIndexDefault as n, createBreadcrumbs as r, buildDocuments as t };
|
package/dist/search/algolia.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as buildIndexDefault, r as createBreadcrumbs } from "../build-index-Bxu0jldy.js";
|
|
2
2
|
import { t as createEndpoint } from "../endpoint-MyoBU5IC.js";
|
|
3
3
|
import { t as buildDocuments } from "../build-doc-C7HYXyRK.js";
|
|
4
4
|
import { n as search, t as createDocument } from "../utils-CbSdov6X.js";
|
|
@@ -89,12 +89,13 @@ function flexsearchFromSource(loader, options = {}) {
|
|
|
89
89
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
90
90
|
const { buildIndex = buildIndexDefault, ...rest } = options;
|
|
91
91
|
async function initServer(loader) {
|
|
92
|
+
const getBreadcrumbs = createBreadcrumbs(loader);
|
|
92
93
|
const indexes = await Promise.all(loader.getPages().map(async (page) => {
|
|
93
94
|
const index = await buildIndex(page);
|
|
94
95
|
return {
|
|
95
96
|
...index,
|
|
96
97
|
locale: page.locale,
|
|
97
|
-
breadcrumbs: index.breadcrumbs ??
|
|
98
|
+
breadcrumbs: index.breadcrumbs ?? getBreadcrumbs(page)
|
|
98
99
|
};
|
|
99
100
|
}));
|
|
100
101
|
if (loader._i18n) return serverI18n({
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as createBreadcrumbs, t as buildDocuments } from "../build-index-Bxu0jldy.js";
|
|
2
2
|
//#region src/search/meilisearch.ts
|
|
3
3
|
/**
|
|
4
4
|
* Build the search documents of every page in a source.
|
|
5
5
|
*/
|
|
6
6
|
async function toDocuments(source, options = {}) {
|
|
7
7
|
const loader = typeof source === "function" ? await source() : source;
|
|
8
|
+
const getBreadcrumbs = createBreadcrumbs(loader);
|
|
8
9
|
return buildDocuments(loader, (index, page) => ({
|
|
9
10
|
title: index.title,
|
|
10
11
|
description: index.description,
|
|
11
|
-
breadcrumbs:
|
|
12
|
+
breadcrumbs: getBreadcrumbs(page),
|
|
12
13
|
url: index.url,
|
|
13
14
|
structured: index.structuredData,
|
|
14
15
|
tag: options.tag?.(page),
|
package/dist/search/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as buildIndexDefault, r as createBreadcrumbs } from "../build-index-Bxu0jldy.js";
|
|
2
2
|
import { n as searchSimple, t as searchAdvanced } from "../advanced-cJMxLDd5.js";
|
|
3
3
|
import { n as defaultReadOptions, t as createEndpoint } from "../endpoint-MyoBU5IC.js";
|
|
4
4
|
import { t as buildDocuments } from "../build-doc-C7HYXyRK.js";
|
|
@@ -186,11 +186,12 @@ function createFromSource(loader, options = {}) {
|
|
|
186
186
|
const { buildIndex = buildIndexDefault } = options;
|
|
187
187
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
188
188
|
async function initServer(loader) {
|
|
189
|
+
const getBreadcrumbs = createBreadcrumbs(loader);
|
|
189
190
|
const indexes = await Promise.all(loader.getPages().map(async (page) => {
|
|
190
191
|
const index = await buildIndex(page);
|
|
191
192
|
return {
|
|
192
193
|
...index,
|
|
193
|
-
breadcrumbs: index.breadcrumbs ??
|
|
194
|
+
breadcrumbs: index.breadcrumbs ?? getBreadcrumbs(page),
|
|
194
195
|
locale: page.locale
|
|
195
196
|
};
|
|
196
197
|
}));
|