fumadocs-core 12.5.2 → 12.5.4
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.
- package/dist/breadcrumb.js +5 -9
- package/dist/chunk-DVOZJZGH.js +42 -0
- package/dist/chunk-KGMG4N3Y.js +13 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/{chunk-EP2HYVJS.js → chunk-V6DBK6TW.js} +1 -1
- package/dist/{chunk-QRNTLL6S.js → chunk-YKIM647L.js} +5 -6
- package/dist/dynamic-link.d.ts +2 -3
- package/dist/dynamic-link.js +5 -9
- package/dist/link.d.ts +5 -11
- package/dist/link.js +2 -2
- package/dist/mdx-plugins/index.js +24 -20
- package/dist/middleware.js +1 -1
- package/dist/search/client.js +10 -14
- package/dist/search/server.js +113 -124
- package/dist/search-algolia/client.js +18 -23
- package/dist/search-algolia/server.js +29 -36
- package/dist/server/index.js +39 -48
- package/dist/sidebar.js +22 -31
- package/dist/source/index.js +51 -52
- package/dist/toc-internal.js +12 -26
- package/dist/toc.js +6 -12
- package/dist/utils/use-on-change.d.ts +3 -0
- package/dist/utils/use-on-change.js +7 -0
- package/package.json +9 -2
- package/dist/chunk-CWMXXUWU.js +0 -63
- package/dist/chunk-XB7CNOKH.js +0 -40
package/dist/search/server.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
__async,
|
|
3
|
-
__spreadProps,
|
|
4
|
-
__spreadValues
|
|
5
|
-
} from "../chunk-CWMXXUWU.js";
|
|
1
|
+
import "../chunk-MLKGABMK.js";
|
|
6
2
|
|
|
7
3
|
// src/search/server.ts
|
|
8
4
|
import { Document } from "flexsearch";
|
|
@@ -10,18 +6,15 @@ import { NextResponse } from "next/server";
|
|
|
10
6
|
function create(search) {
|
|
11
7
|
return {
|
|
12
8
|
search,
|
|
13
|
-
GET(request) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
});
|
|
9
|
+
async GET(request) {
|
|
10
|
+
const query = request.nextUrl.searchParams.get("query");
|
|
11
|
+
if (!query) return NextResponse.json([]);
|
|
12
|
+
return NextResponse.json(
|
|
13
|
+
await search(query, {
|
|
14
|
+
tag: request.nextUrl.searchParams.get("tag") ?? void 0,
|
|
15
|
+
locale: request.nextUrl.searchParams.get("locale") ?? void 0
|
|
16
|
+
})
|
|
17
|
+
);
|
|
25
18
|
}
|
|
26
19
|
};
|
|
27
20
|
}
|
|
@@ -38,68 +31,67 @@ function createI18nSearchAPI(type, options) {
|
|
|
38
31
|
map.set(
|
|
39
32
|
v.language,
|
|
40
33
|
// @ts-expect-error -- Index depends on generic types
|
|
41
|
-
createSearchAPI(type,
|
|
34
|
+
createSearchAPI(type, {
|
|
35
|
+
...options,
|
|
42
36
|
language: v.language,
|
|
43
37
|
indexes: v.indexes
|
|
44
|
-
})
|
|
38
|
+
})
|
|
45
39
|
);
|
|
46
40
|
}
|
|
47
|
-
return create((query, searchOptions) =>
|
|
48
|
-
if (searchOptions
|
|
41
|
+
return create(async (query, searchOptions) => {
|
|
42
|
+
if (searchOptions?.locale) {
|
|
49
43
|
const handler = map.get(searchOptions.locale);
|
|
50
44
|
if (handler) return handler.search(query, searchOptions);
|
|
51
45
|
}
|
|
52
46
|
return [];
|
|
53
|
-
})
|
|
47
|
+
});
|
|
54
48
|
}
|
|
55
49
|
function initSearchAPI({ indexes, language }) {
|
|
56
50
|
const store = ["title", "url"];
|
|
57
|
-
function getDocument() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
depth: 1,
|
|
78
|
-
resolution: 9
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
field: "keywords",
|
|
83
|
-
tokenize: "strict",
|
|
51
|
+
async function getDocument() {
|
|
52
|
+
const items = typeof indexes === "function" ? await indexes() : indexes;
|
|
53
|
+
const index = new Document({
|
|
54
|
+
language,
|
|
55
|
+
optimize: true,
|
|
56
|
+
cache: 100,
|
|
57
|
+
document: {
|
|
58
|
+
id: "url",
|
|
59
|
+
store,
|
|
60
|
+
index: [
|
|
61
|
+
{
|
|
62
|
+
field: "title",
|
|
63
|
+
tokenize: "forward",
|
|
64
|
+
resolution: 9
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
field: "content",
|
|
68
|
+
tokenize: "strict",
|
|
69
|
+
context: {
|
|
70
|
+
depth: 1,
|
|
84
71
|
resolution: 9
|
|
85
72
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
content: page.content,
|
|
94
|
-
keywords: page.keywords
|
|
95
|
-
});
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
field: "keywords",
|
|
76
|
+
tokenize: "strict",
|
|
77
|
+
resolution: 9
|
|
78
|
+
}
|
|
79
|
+
]
|
|
96
80
|
}
|
|
97
|
-
return index;
|
|
98
81
|
});
|
|
82
|
+
for (const page of items) {
|
|
83
|
+
index.add({
|
|
84
|
+
title: page.title,
|
|
85
|
+
url: page.url,
|
|
86
|
+
content: page.content,
|
|
87
|
+
keywords: page.keywords
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return index;
|
|
99
91
|
}
|
|
100
92
|
const doc = getDocument();
|
|
101
|
-
return create((query) =>
|
|
102
|
-
const results = (
|
|
93
|
+
return create(async (query) => {
|
|
94
|
+
const results = (await doc).search(query, 5, {
|
|
103
95
|
enrich: true,
|
|
104
96
|
suggest: true
|
|
105
97
|
});
|
|
@@ -110,7 +102,7 @@ function initSearchAPI({ indexes, language }) {
|
|
|
110
102
|
id: page.doc.url,
|
|
111
103
|
url: page.doc.url
|
|
112
104
|
}));
|
|
113
|
-
})
|
|
105
|
+
});
|
|
114
106
|
}
|
|
115
107
|
function initSearchAPIAdvanced({
|
|
116
108
|
indexes,
|
|
@@ -118,85 +110,82 @@ function initSearchAPIAdvanced({
|
|
|
118
110
|
tag = false
|
|
119
111
|
}) {
|
|
120
112
|
const store = ["id", "url", "content", "page_id", "type", "keywords"];
|
|
121
|
-
function getDocument() {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
113
|
+
async function getDocument() {
|
|
114
|
+
const items = typeof indexes === "function" ? await indexes() : indexes;
|
|
115
|
+
const index = new Document({
|
|
116
|
+
language,
|
|
117
|
+
cache: 100,
|
|
118
|
+
optimize: true,
|
|
119
|
+
document: {
|
|
120
|
+
id: "id",
|
|
121
|
+
tag: tag ? "tag" : void 0,
|
|
122
|
+
store,
|
|
123
|
+
index: [
|
|
124
|
+
{
|
|
125
|
+
field: "content",
|
|
126
|
+
tokenize: "forward",
|
|
127
|
+
context: { depth: 2, bidirectional: true, resolution: 9 }
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
field: "keywords",
|
|
131
|
+
tokenize: "strict",
|
|
132
|
+
resolution: 9
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
for (const page of items) {
|
|
138
|
+
const data = page.structuredData;
|
|
139
|
+
let id = 0;
|
|
140
|
+
index.add({
|
|
141
|
+
id: page.id,
|
|
142
|
+
page_id: page.id,
|
|
143
|
+
type: "page",
|
|
144
|
+
content: page.title,
|
|
145
|
+
keywords: page.keywords,
|
|
146
|
+
tag: page.tag,
|
|
147
|
+
url: page.url
|
|
145
148
|
});
|
|
146
|
-
for (const
|
|
147
|
-
const data = page.structuredData;
|
|
148
|
-
let id = 0;
|
|
149
|
+
for (const heading of data.headings) {
|
|
149
150
|
index.add({
|
|
150
|
-
id: page.id,
|
|
151
|
+
id: page.id + (id++).toString(),
|
|
151
152
|
page_id: page.id,
|
|
152
|
-
type: "
|
|
153
|
-
content: page.title,
|
|
154
|
-
keywords: page.keywords,
|
|
153
|
+
type: "heading",
|
|
155
154
|
tag: page.tag,
|
|
156
|
-
url: page.url
|
|
155
|
+
url: `${page.url}#${heading.id}`,
|
|
156
|
+
content: heading.content
|
|
157
157
|
});
|
|
158
|
-
for (const heading of data.headings) {
|
|
159
|
-
index.add({
|
|
160
|
-
id: page.id + (id++).toString(),
|
|
161
|
-
page_id: page.id,
|
|
162
|
-
type: "heading",
|
|
163
|
-
tag: page.tag,
|
|
164
|
-
url: `${page.url}#${heading.id}`,
|
|
165
|
-
content: heading.content
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
for (const content of data.contents) {
|
|
169
|
-
index.add({
|
|
170
|
-
id: page.id + (id++).toString(),
|
|
171
|
-
page_id: page.id,
|
|
172
|
-
tag: page.tag,
|
|
173
|
-
type: "text",
|
|
174
|
-
url: content.heading ? `${page.url}#${content.heading}` : page.url,
|
|
175
|
-
content: content.content
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
158
|
}
|
|
179
|
-
|
|
180
|
-
|
|
159
|
+
for (const content of data.contents) {
|
|
160
|
+
index.add({
|
|
161
|
+
id: page.id + (id++).toString(),
|
|
162
|
+
page_id: page.id,
|
|
163
|
+
tag: page.tag,
|
|
164
|
+
type: "text",
|
|
165
|
+
url: content.heading ? `${page.url}#${content.heading}` : page.url,
|
|
166
|
+
content: content.content
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return index;
|
|
181
171
|
}
|
|
182
172
|
const doc = getDocument();
|
|
183
|
-
return create((query, options) =>
|
|
184
|
-
|
|
185
|
-
const index = yield doc;
|
|
173
|
+
return create(async (query, options) => {
|
|
174
|
+
const index = await doc;
|
|
186
175
|
const results = index.search(query, 5, {
|
|
187
176
|
enrich: true,
|
|
188
|
-
tag: options
|
|
177
|
+
tag: options?.tag,
|
|
189
178
|
limit: 6
|
|
190
179
|
});
|
|
191
180
|
const map = /* @__PURE__ */ new Map();
|
|
192
|
-
for (const item of
|
|
181
|
+
for (const item of results[0]?.result ?? []) {
|
|
193
182
|
if (item.doc.type === "page") {
|
|
194
183
|
if (!map.has(item.doc.id)) {
|
|
195
184
|
map.set(item.doc.id, []);
|
|
196
185
|
}
|
|
197
186
|
continue;
|
|
198
187
|
}
|
|
199
|
-
const list =
|
|
188
|
+
const list = map.get(item.doc.page_id) ?? [];
|
|
200
189
|
list.push({
|
|
201
190
|
id: item.doc.id,
|
|
202
191
|
content: item.doc.content,
|
|
@@ -218,7 +207,7 @@ function initSearchAPIAdvanced({
|
|
|
218
207
|
sortedResult.push(...items);
|
|
219
208
|
}
|
|
220
209
|
return sortedResult;
|
|
221
|
-
})
|
|
210
|
+
});
|
|
222
211
|
}
|
|
223
212
|
export {
|
|
224
213
|
createI18nSearchAPI,
|
|
@@ -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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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,
|
|
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
|
-
() =>
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
32
|
-
section_id: heading
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,
|
package/dist/server/index.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
remarkHeading
|
|
3
|
-
} from "../chunk-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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:
|
|
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(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"as"
|
|
37
|
-
]);
|
|
27
|
+
function SidebarTrigger({
|
|
28
|
+
as,
|
|
29
|
+
...props
|
|
30
|
+
}) {
|
|
38
31
|
const [open, setOpen] = useSidebarContext();
|
|
39
|
-
const As = as
|
|
32
|
+
const As = as ?? "button";
|
|
40
33
|
return /* @__PURE__ */ jsx(
|
|
41
34
|
As,
|
|
42
|
-
|
|
35
|
+
{
|
|
43
36
|
"aria-label": "Toggle Sidebar",
|
|
44
37
|
"data-open": open,
|
|
45
38
|
onClick: useCallback(() => {
|
|
46
39
|
setOpen(!open);
|
|
47
|
-
}, [open, setOpen])
|
|
48
|
-
|
|
40
|
+
}, [open, setOpen]),
|
|
41
|
+
...props
|
|
42
|
+
}
|
|
49
43
|
);
|
|
50
44
|
}
|
|
51
|
-
function SidebarList(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
78
|
-
as: as
|
|
68
|
+
{
|
|
69
|
+
as: as ?? "aside",
|
|
79
70
|
"data-open": open,
|
|
80
|
-
enabled: Boolean(isBlocking && open)
|
|
81
|
-
|
|
71
|
+
enabled: Boolean(isBlocking && open),
|
|
72
|
+
...props,
|
|
82
73
|
children: props.children
|
|
83
|
-
}
|
|
74
|
+
}
|
|
84
75
|
);
|
|
85
76
|
}
|
|
86
77
|
export {
|