fumadocs-core 12.5.3 → 12.5.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,8 +1,4 @@
1
- import {
2
- __async,
3
- __objRest,
4
- __spreadValues
5
- } from "../chunk-CWMXXUWU.js";
1
+ import "../chunk-MLKGABMK.js";
6
2
 
7
3
  // src/search-algolia/client.ts
8
4
  import { useState } from "react";
@@ -29,31 +25,30 @@ function groupResults(hits) {
29
25
  }
30
26
  return grouped;
31
27
  }
32
- function searchDocs(index, query, options) {
33
- return __async(this, null, function* () {
34
- if (query.length === 0) {
35
- const result2 = yield index.search(query, __spreadValues({
36
- distinct: 1,
37
- hitsPerPage: 8
38
- }, options));
39
- return groupResults(result2.hits).filter((hit) => hit.type === "page");
40
- }
41
- const result = yield index.search(query, __spreadValues({
42
- distinct: 5,
43
- hitsPerPage: 10
44
- }, options));
45
- return groupResults(result.hits);
28
+ async function searchDocs(index, query, options) {
29
+ if (query.length === 0) {
30
+ const result2 = await index.search(query, {
31
+ distinct: 1,
32
+ hitsPerPage: 8,
33
+ ...options
34
+ });
35
+ return groupResults(result2.hits).filter((hit) => hit.type === "page");
36
+ }
37
+ const result = await index.search(query, {
38
+ distinct: 5,
39
+ hitsPerPage: 10,
40
+ ...options
46
41
  });
42
+ return groupResults(result.hits);
47
43
  }
48
- function useAlgoliaSearch(index, _a = {}) {
49
- var _b = _a, { allowEmpty = true } = _b, options = __objRest(_b, ["allowEmpty"]);
44
+ function useAlgoliaSearch(index, { allowEmpty = true, ...options } = {}) {
50
45
  const [search, setSearch] = useState("");
51
46
  const query = useSWR(
52
47
  ["algolia-search", search, allowEmpty, options],
53
- () => __async(this, null, function* () {
48
+ async () => {
54
49
  if (allowEmpty && search.length === 0) return "empty";
55
50
  return searchDocs(index, search, options);
56
- }),
51
+ },
57
52
  {
58
53
  keepPreviousData: true
59
54
  }
@@ -1,26 +1,19 @@
1
- import {
2
- __async,
3
- __spreadValues
4
- } from "../chunk-CWMXXUWU.js";
1
+ import "../chunk-MLKGABMK.js";
5
2
 
6
3
  // src/search-algolia/server.ts
7
- function sync(client, options) {
8
- return __async(this, null, function* () {
9
- const { document = "document", documents } = options;
10
- const index = client.initIndex(document);
11
- yield setIndexSettings(index);
12
- yield updateDocuments(index, documents);
13
- });
4
+ async function sync(client, options) {
5
+ const { document = "document", documents } = options;
6
+ const index = client.initIndex(document);
7
+ await setIndexSettings(index);
8
+ await updateDocuments(index, documents);
14
9
  }
15
- function setIndexSettings(index) {
16
- return __async(this, null, function* () {
17
- yield index.setSettings({
18
- attributeForDistinct: "page_id",
19
- attributesToRetrieve: ["title", "section", "content", "url", "section_id"],
20
- searchableAttributes: ["title", "section", "content"],
21
- attributesToSnippet: [],
22
- attributesForFaceting: ["tag"]
23
- });
10
+ async function setIndexSettings(index) {
11
+ await index.setSettings({
12
+ attributeForDistinct: "page_id",
13
+ attributesToRetrieve: ["title", "section", "content", "url", "section_id"],
14
+ searchableAttributes: ["title", "section", "content"],
15
+ attributesToSnippet: [],
16
+ attributesForFaceting: ["tag"]
24
17
  });
25
18
  }
26
19
  function getSections(page) {
@@ -28,8 +21,8 @@ function getSections(page) {
28
21
  return page.structured.contents.flatMap((p) => {
29
22
  const heading = p.heading ? page.structured.headings.find((h) => p.heading === h.id) : null;
30
23
  const section = {
31
- section: heading == null ? void 0 : heading.content,
32
- section_id: heading == null ? void 0 : heading.id,
24
+ section: heading?.content,
25
+ section_id: heading?.id,
33
26
  content: p.content
34
27
  };
35
28
  if (heading && !scannedHeadings.has(heading.id)) {
@@ -46,21 +39,21 @@ function getSections(page) {
46
39
  return section;
47
40
  });
48
41
  }
49
- function updateDocuments(index, documents) {
50
- return __async(this, null, function* () {
51
- const objects = documents.flatMap((page) => {
52
- return getSections(page).map(
53
- (section, idx) => __spreadValues(__spreadValues({
54
- objectID: `${page._id}-${idx.toString()}`,
55
- title: page.title,
56
- url: page.url,
57
- page_id: page._id,
58
- tag: page.tag
59
- }, section), page.extra_data)
60
- );
61
- });
62
- yield index.replaceAllObjects(objects);
42
+ async function updateDocuments(index, documents) {
43
+ const objects = documents.flatMap((page) => {
44
+ return getSections(page).map(
45
+ (section, idx) => ({
46
+ objectID: `${page._id}-${idx.toString()}`,
47
+ title: page.title,
48
+ url: page.url,
49
+ page_id: page._id,
50
+ tag: page.tag,
51
+ ...section,
52
+ ...page.extra_data
53
+ })
54
+ );
63
55
  });
56
+ await index.replaceAllObjects(objects);
64
57
  }
65
58
  export {
66
59
  setIndexSettings,
@@ -1,20 +1,14 @@
1
1
  import {
2
2
  remarkHeading
3
- } from "../chunk-QRNTLL6S.js";
4
- import {
5
- __async,
6
- __spreadProps,
7
- __spreadValues
8
- } from "../chunk-CWMXXUWU.js";
3
+ } from "../chunk-YKIM647L.js";
4
+ import "../chunk-MLKGABMK.js";
9
5
 
10
6
  // src/server/get-toc.ts
11
7
  import { remark } from "remark";
12
- function getTableOfContents(content) {
13
- return __async(this, null, function* () {
14
- const result = yield remark().use(remarkHeading).process(content);
15
- if ("toc" in result.data) return result.data.toc;
16
- return [];
17
- });
8
+ async function getTableOfContents(content) {
9
+ const result = await remark().use(remarkHeading).process(content);
10
+ if ("toc" in result.data) return result.data.toc;
11
+ return [];
18
12
  }
19
13
 
20
14
  // src/server/page-tree-utils.ts
@@ -43,11 +37,10 @@ function findNeighbour(tree, url) {
43
37
  }
44
38
  function separatePageTree(pageTree) {
45
39
  return pageTree.children.flatMap((child) => {
46
- var _a;
47
40
  if (child.type !== "folder") return [];
48
41
  return {
49
42
  name: child.name,
50
- url: (_a = child.index) == null ? void 0 : _a.url,
43
+ url: child.index?.url,
51
44
  children: child.children
52
45
  };
53
46
  });
@@ -57,42 +50,40 @@ function separatePageTree(pageTree) {
57
50
  var page_tree_exports = {};
58
51
 
59
52
  // src/server/git-api.ts
60
- function getGithubLastEdit(_0) {
61
- return __async(this, arguments, function* ({
62
- repo,
63
- token,
64
- owner,
65
- path,
66
- options = {},
67
- params: customParams = {}
68
- }) {
69
- const headers = new Headers(options.headers);
70
- const params = new URLSearchParams();
71
- params.set("path", path);
72
- params.set("page", "1");
73
- params.set("per_page", "1");
74
- for (const [key, value] of Object.entries(customParams)) {
75
- params.set(key, value);
76
- }
77
- if (token) {
78
- headers.append("authorization", token);
53
+ async function getGithubLastEdit({
54
+ repo,
55
+ token,
56
+ owner,
57
+ path,
58
+ options = {},
59
+ params: customParams = {}
60
+ }) {
61
+ const headers = new Headers(options.headers);
62
+ const params = new URLSearchParams();
63
+ params.set("path", path);
64
+ params.set("page", "1");
65
+ params.set("per_page", "1");
66
+ for (const [key, value] of Object.entries(customParams)) {
67
+ params.set(key, value);
68
+ }
69
+ if (token) {
70
+ headers.append("authorization", token);
71
+ }
72
+ const res = await fetch(
73
+ `https://api.github.com/repos/${owner}/${repo}/commits?${params.toString()}`,
74
+ {
75
+ cache: "force-cache",
76
+ ...options,
77
+ headers
79
78
  }
80
- const res = yield fetch(
81
- `https://api.github.com/repos/${owner}/${repo}/commits?${params.toString()}`,
82
- __spreadProps(__spreadValues({
83
- cache: "force-cache"
84
- }, options), {
85
- headers
86
- })
79
+ );
80
+ if (!res.ok)
81
+ throw new Error(
82
+ `Failed to fetch last edit time from Git ${await res.text()}`
87
83
  );
88
- if (!res.ok)
89
- throw new Error(
90
- `Failed to fetch last edit time from Git ${yield res.text()}`
91
- );
92
- const data = yield res.json();
93
- if (data.length === 0) return null;
94
- return new Date(data[0].commit.committer.date);
95
- });
84
+ const data = await res.json();
85
+ if (data.length === 0) return null;
86
+ return new Date(data[0].commit.committer.date);
96
87
  }
97
88
  export {
98
89
  page_tree_exports as PageTree,
package/dist/sidebar.js CHANGED
@@ -1,8 +1,4 @@
1
- import {
2
- __objRest,
3
- __spreadProps,
4
- __spreadValues
5
- } from "./chunk-CWMXXUWU.js";
1
+ import "./chunk-MLKGABMK.js";
6
2
 
7
3
  // src/sidebar.tsx
8
4
  import {
@@ -21,41 +17,36 @@ function useSidebarContext() {
21
17
  return ctx;
22
18
  }
23
19
  function SidebarProvider(props) {
24
- var _a, _b;
25
20
  const [openInner, setOpenInner] = useState(false);
26
21
  const [open, setOpen] = [
27
- (_a = props.open) != null ? _a : openInner,
28
- (_b = props.onOpenChange) != null ? _b : setOpenInner
22
+ props.open ?? openInner,
23
+ props.onOpenChange ?? setOpenInner
29
24
  ];
30
25
  return /* @__PURE__ */ jsx(SidebarContext.Provider, { value: [open, setOpen], children: props.children });
31
26
  }
32
- function SidebarTrigger(_a) {
33
- var _b = _a, {
34
- as
35
- } = _b, props = __objRest(_b, [
36
- "as"
37
- ]);
27
+ function SidebarTrigger({
28
+ as,
29
+ ...props
30
+ }) {
38
31
  const [open, setOpen] = useSidebarContext();
39
- const As = as != null ? as : "button";
32
+ const As = as ?? "button";
40
33
  return /* @__PURE__ */ jsx(
41
34
  As,
42
- __spreadValues({
35
+ {
43
36
  "aria-label": "Toggle Sidebar",
44
37
  "data-open": open,
45
38
  onClick: useCallback(() => {
46
39
  setOpen(!open);
47
- }, [open, setOpen])
48
- }, props)
40
+ }, [open, setOpen]),
41
+ ...props
42
+ }
49
43
  );
50
44
  }
51
- function SidebarList(_a) {
52
- var _b = _a, {
53
- as,
54
- blockScrollingWidth
55
- } = _b, props = __objRest(_b, [
56
- "as",
57
- "blockScrollingWidth"
58
- ]);
45
+ function SidebarList({
46
+ as,
47
+ blockScrollingWidth,
48
+ ...props
49
+ }) {
59
50
  const [open] = useSidebarContext();
60
51
  const [isBlocking, setIsBlocking] = useState(false);
61
52
  useEffect(() => {
@@ -74,13 +65,13 @@ function SidebarList(_a) {
74
65
  }, [blockScrollingWidth]);
75
66
  return /* @__PURE__ */ jsx(
76
67
  RemoveScroll,
77
- __spreadProps(__spreadValues({
78
- as: as != null ? as : "aside",
68
+ {
69
+ as: as ?? "aside",
79
70
  "data-open": open,
80
- enabled: Boolean(isBlocking && open)
81
- }, props), {
71
+ enabled: Boolean(isBlocking && open),
72
+ ...props,
82
73
  children: props.children
83
- })
74
+ }
84
75
  );
85
76
  }
86
77
  export {
@@ -2,10 +2,8 @@ import {
2
2
  slash
3
3
  } from "../chunk-UWEEHUJV.js";
4
4
  import {
5
- __export,
6
- __objRest,
7
- __spreadValues
8
- } from "../chunk-CWMXXUWU.js";
5
+ __export
6
+ } from "../chunk-MLKGABMK.js";
9
7
 
10
8
  // src/source/path.ts
11
9
  import { parse } from "path";
@@ -61,8 +59,9 @@ function resolvePath(from, join) {
61
59
  }
62
60
 
63
61
  // src/source/page-tree-builder.ts
64
- var link = new RegExp("^\\[(?<text>.+)]\\((?<url>.+)\\)$");
65
- var separator = new RegExp("^---(?<name>.*?)---$");
62
+ var group = /^\((?<name>.+)\)$/;
63
+ var link = /^\[(?<text>.+)]\((?<url>.+)\)$/;
64
+ var separator = /^---(?<name>.*?)---$/;
66
65
  var rest = "...";
67
66
  function buildAll(nodes, ctx, skipIndex) {
68
67
  const output = [];
@@ -84,18 +83,17 @@ function buildAll(nodes, ctx, skipIndex) {
84
83
  return output;
85
84
  }
86
85
  function resolveFolderItem(folder, item, ctx, addedNodePaths) {
87
- var _a, _b, _c, _d, _e, _f, _g;
88
86
  if (item === rest) return "...";
89
87
  const separateResult = separator.exec(item);
90
- if (separateResult == null ? void 0 : separateResult.groups) {
88
+ if (separateResult?.groups) {
91
89
  const node = {
92
90
  type: "separator",
93
91
  name: separateResult.groups.name
94
92
  };
95
- return [(_c = (_b = (_a = ctx.options).attachSeparator) == null ? void 0 : _b.call(_a, node)) != null ? _c : node];
93
+ return [ctx.options.attachSeparator?.(node) ?? node];
96
94
  }
97
95
  const linkResult = link.exec(item);
98
- if (linkResult == null ? void 0 : linkResult.groups) {
96
+ if (linkResult?.groups) {
99
97
  const { url, text } = linkResult.groups;
100
98
  const isRelative = url.startsWith("/") || url.startsWith("#") || url.startsWith(".");
101
99
  const node = {
@@ -104,7 +102,7 @@ function resolveFolderItem(folder, item, ctx, addedNodePaths) {
104
102
  url,
105
103
  external: !isRelative
106
104
  };
107
- return [(_f = (_e = (_d = ctx.options).attachFile) == null ? void 0 : _e.call(_d, node)) != null ? _f : node];
105
+ return [ctx.options.attachFile?.(node) ?? node];
108
106
  }
109
107
  let filename = item;
110
108
  const isExcept = item.startsWith("!");
@@ -116,7 +114,7 @@ function resolveFolderItem(folder, item, ctx, addedNodePaths) {
116
114
  filename = item.slice(3);
117
115
  }
118
116
  const path = resolvePath(folder.file.path, filename);
119
- const itemNode = (_g = ctx.storage.readDir(path)) != null ? _g : ctx.storage.read(path, "page");
117
+ const itemNode = ctx.storage.readDir(path) ?? ctx.storage.read(path, "page");
120
118
  if (!itemNode) return [];
121
119
  addedNodePaths.add(itemNode.file.path);
122
120
  if (isExcept) return [];
@@ -127,23 +125,22 @@ function resolveFolderItem(folder, item, ctx, addedNodePaths) {
127
125
  return [buildFileNode(itemNode, ctx)];
128
126
  }
129
127
  function buildFolderNode(folder, defaultIsRoot, ctx) {
130
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
131
128
  const metaPath = resolvePath(folder.file.path, "meta");
132
129
  let meta = ctx.storage.read(metaPath, "meta");
133
- meta = (_a = findLocalizedFile(metaPath, "meta", ctx)) != null ? _a : meta;
130
+ meta = findLocalizedFile(metaPath, "meta", ctx) ?? meta;
134
131
  const indexFile = ctx.storage.read(
135
132
  resolvePath(folder.file.flattenedPath, "index"),
136
133
  "page"
137
134
  );
138
- const metadata = meta == null ? void 0 : meta.data.data;
135
+ const metadata = meta?.data.data;
139
136
  const index = indexFile ? buildFileNode(indexFile, ctx) : void 0;
140
137
  let children;
141
138
  if (!meta) {
142
139
  children = buildAll(folder.children, ctx, !defaultIsRoot);
143
140
  } else {
144
- const isRoot = (_b = metadata == null ? void 0 : metadata.root) != null ? _b : defaultIsRoot;
141
+ const isRoot = metadata?.root ?? defaultIsRoot;
145
142
  const addedNodePaths = /* @__PURE__ */ new Set();
146
- const resolved = (_c = metadata == null ? void 0 : metadata.pages) == null ? void 0 : _c.flatMap((item) => {
143
+ const resolved = metadata?.pages?.flatMap((item) => {
147
144
  return resolveFolderItem(folder, item, ctx, addedNodePaths);
148
145
  });
149
146
  const restNodes = buildAll(
@@ -151,20 +148,20 @@ function buildFolderNode(folder, defaultIsRoot, ctx) {
151
148
  ctx,
152
149
  !isRoot
153
150
  );
154
- const nodes = resolved == null ? void 0 : resolved.flatMap((item) => {
151
+ const nodes = resolved?.flatMap((item) => {
155
152
  if (item === "...") {
156
153
  return restNodes;
157
154
  }
158
155
  return item;
159
156
  });
160
- children = nodes != null ? nodes : restNodes;
157
+ children = nodes ?? restNodes;
161
158
  }
162
159
  const node = {
163
160
  type: "folder",
164
- name: (_e = (_d = metadata == null ? void 0 : metadata.title) != null ? _d : index == null ? void 0 : index.name) != null ? _e : pathToName(folder.file.name),
165
- icon: (_g = (_f = ctx.options).resolveIcon) == null ? void 0 : _g.call(_f, metadata == null ? void 0 : metadata.icon),
166
- root: metadata == null ? void 0 : metadata.root,
167
- defaultOpen: metadata == null ? void 0 : metadata.defaultOpen,
161
+ name: metadata?.title ?? index?.name ?? pathToName(folder.file.name, true),
162
+ icon: ctx.options.resolveIcon?.(metadata?.icon),
163
+ root: metadata?.root,
164
+ defaultOpen: metadata?.defaultOpen,
168
165
  index,
169
166
  children
170
167
  };
@@ -172,20 +169,19 @@ function buildFolderNode(folder, defaultIsRoot, ctx) {
172
169
  node.id = folder.file.flattenedPath;
173
170
  }
174
171
  return removeUndefined(
175
- (_j = (_i = (_h = ctx.options).attachFolder) == null ? void 0 : _i.call(_h, node, folder, meta)) != null ? _j : node
172
+ ctx.options.attachFolder?.(node, folder, meta) ?? node
176
173
  );
177
174
  }
178
175
  function buildFileNode(file, ctx) {
179
- var _a, _b, _c, _d, _e, _f;
180
- const localized = (_a = findLocalizedFile(file.file.flattenedPath, "page", ctx)) != null ? _a : file;
176
+ const localized = findLocalizedFile(file.file.flattenedPath, "page", ctx) ?? file;
181
177
  const data = localized.data;
182
178
  const item = {
183
179
  type: "page",
184
180
  name: data.data.title,
185
- icon: (_c = (_b = ctx.options).resolveIcon) == null ? void 0 : _c.call(_b, data.data.icon),
181
+ icon: ctx.options.resolveIcon?.(data.data.icon),
186
182
  url: ctx.options.getUrl(data.slugs, ctx.lang)
187
183
  };
188
- return removeUndefined((_f = (_e = (_d = ctx.options).attachFile) == null ? void 0 : _e.call(_d, item, file)) != null ? _f : item);
184
+ return removeUndefined(ctx.options.attachFile?.(item, file) ?? item);
189
185
  }
190
186
  function build(ctx) {
191
187
  const root = ctx.storage.root();
@@ -204,8 +200,7 @@ function createPageTreeBuilder() {
204
200
  storage: options.storage
205
201
  });
206
202
  },
207
- buildI18n(_a) {
208
- var _b = _a, { languages = [], defaultLanguage } = _b, options = __objRest(_b, ["languages", "defaultLanguage"]);
203
+ buildI18n({ languages = [], defaultLanguage, ...options }) {
209
204
  const entries = languages.map((lang) => {
210
205
  const tree = build({
211
206
  lang: lang === defaultLanguage ? void 0 : lang,
@@ -223,8 +218,15 @@ function findLocalizedFile(path, format, ctx) {
223
218
  if (!ctx.lang) return;
224
219
  return ctx.storage.read(`${path}.${ctx.lang}`, format);
225
220
  }
226
- function pathToName(path) {
227
- return path.slice(0, 1).toUpperCase() + path.slice(1);
221
+ function pathToName(name, resolveGroup = false) {
222
+ const resolved = resolveGroup ? group.exec(name)?.[1] ?? name : name;
223
+ const result = [];
224
+ for (const c of resolved) {
225
+ if (result.length === 0) result.push(c.toLocaleUpperCase());
226
+ else if (c === "-") result.push(" ");
227
+ else result.push(c);
228
+ }
229
+ return result.join("");
228
230
  }
229
231
  function removeUndefined(value) {
230
232
  const obj = value;
@@ -263,21 +265,19 @@ var Storage = class {
263
265
  return this.rootFolder;
264
266
  }
265
267
  write(path, format, data) {
266
- var _a;
267
268
  const node = {
268
269
  format,
269
270
  file: parseFilePath(path),
270
271
  data
271
272
  };
272
273
  this.makeDir(node.file.dirname);
273
- (_a = this.readDir(node.file.dirname)) == null ? void 0 : _a.children.push(node);
274
+ this.readDir(node.file.dirname)?.children.push(node);
274
275
  this.files.set(`${node.file.flattenedPath}.${node.format}`, node);
275
276
  }
276
277
  list() {
277
278
  return [...this.files.values()];
278
279
  }
279
280
  makeDir(path) {
280
- var _a;
281
281
  const segments = splitPath(path);
282
282
  for (let i = 0; i < segments.length; i++) {
283
283
  const segment = segments.slice(0, i + 1).join("/");
@@ -287,17 +287,16 @@ var Storage = class {
287
287
  children: []
288
288
  };
289
289
  this.folders.set(folder.file.path, folder);
290
- (_a = this.readDir(folder.file.dirname)) == null ? void 0 : _a.children.push(folder);
290
+ this.readDir(folder.file.dirname)?.children.push(folder);
291
291
  }
292
292
  }
293
293
  };
294
294
 
295
295
  // src/source/load-files.ts
296
296
  function loadFiles(files, options) {
297
- var _a;
298
297
  const { transformers = [] } = options;
299
298
  const storage = new Storage();
300
- const rootDir = normalizePath((_a = options.rootDir) != null ? _a : "");
299
+ const rootDir = normalizePath(options.rootDir ?? "");
301
300
  for (const file of files) {
302
301
  const normalizedPath = normalizePath(file.path);
303
302
  if (!normalizedPath.startsWith(rootDir)) continue;
@@ -327,7 +326,6 @@ function loadFiles(files, options) {
327
326
 
328
327
  // src/source/loader.ts
329
328
  function buildPageMap(storage, languages, getUrl) {
330
- var _a;
331
329
  const map = /* @__PURE__ */ new Map();
332
330
  const defaultMap = /* @__PURE__ */ new Map();
333
331
  map.set("", defaultMap);
@@ -336,12 +334,12 @@ function buildPageMap(storage, languages, getUrl) {
336
334
  const page = fileToPage(file, getUrl);
337
335
  defaultMap.set(page.slugs.join("/"), page);
338
336
  for (const lang of languages) {
339
- const langMap = (_a = map.get(lang)) != null ? _a : /* @__PURE__ */ new Map();
337
+ const langMap = map.get(lang) ?? /* @__PURE__ */ new Map();
340
338
  const localized = storage.read(
341
339
  `${file.file.flattenedPath}.${lang}`,
342
340
  "page"
343
341
  );
344
- const localizedPage = fileToPage(localized != null ? localized : file, getUrl, lang);
342
+ const localizedPage = fileToPage(localized ?? file, getUrl, lang);
345
343
  langMap.set(localizedPage.slugs.join("/"), localizedPage);
346
344
  map.set(lang, langMap);
347
345
  }
@@ -356,7 +354,8 @@ function createGetUrl(baseUrl) {
356
354
  }
357
355
  function getSlugs(info) {
358
356
  const result = [...info.dirname.split("/"), info.name].filter(
359
- (v) => v.length > 0
357
+ // filter empty folder names and file groups like (group_name)
358
+ (v) => v.length > 0 && !/^\(.+\)$/.test(v)
360
359
  );
361
360
  return result[result.length - 1] === "index" ? result.slice(0, -1) : result;
362
361
  }
@@ -383,25 +382,26 @@ function createOutput({
383
382
  getSlugs: slugsFn
384
383
  }
385
384
  );
386
- const i18nMap = buildPageMap(storage, languages != null ? languages : [], getUrl);
385
+ const i18nMap = buildPageMap(storage, languages ?? [], getUrl);
387
386
  const builder = createPageTreeBuilder();
388
- const pageTree = languages === void 0 ? builder.build(__spreadValues({
387
+ const pageTree = languages === void 0 ? builder.build({
389
388
  storage,
390
389
  resolveIcon,
391
- getUrl
392
- }, pageTreeOptions)) : builder.buildI18n(__spreadValues({
390
+ getUrl,
391
+ ...pageTreeOptions
392
+ }) : builder.buildI18n({
393
393
  languages,
394
394
  storage,
395
395
  resolveIcon,
396
396
  getUrl,
397
- defaultLanguage
398
- }, pageTreeOptions));
397
+ defaultLanguage,
398
+ ...pageTreeOptions
399
+ });
399
400
  return {
400
401
  pageTree,
401
402
  files: storage.list(),
402
403
  getPages(language = "") {
403
- var _a, _b;
404
- return Array.from((_b = (_a = i18nMap.get(language)) == null ? void 0 : _a.values()) != null ? _b : []);
404
+ return Array.from(i18nMap.get(language)?.values() ?? []);
405
405
  },
406
406
  getLanguages() {
407
407
  const list = [];
@@ -415,8 +415,7 @@ function createOutput({
415
415
  return list;
416
416
  },
417
417
  getPage(slugs = [], language = "") {
418
- var _a;
419
- return (_a = i18nMap.get(language)) == null ? void 0 : _a.get(slugs.join("/"));
418
+ return i18nMap.get(language)?.get(slugs.join("/"));
420
419
  }
421
420
  };
422
421
  }