@farming-labs/theme 0.2.117 → 0.2.118
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/docs-api.d.mts +1 -0
- package/dist/docs-api.mjs +384 -130
- package/dist/docs-layout.mjs +330 -72
- package/dist/get-app-dir.mjs +9 -1
- package/package.json +2 -2
package/dist/docs-layout.mjs
CHANGED
|
@@ -14,12 +14,21 @@ import path from "node:path";
|
|
|
14
14
|
import matter from "gray-matter";
|
|
15
15
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
16
16
|
import { Suspense, cloneElement, isValidElement } from "react";
|
|
17
|
-
import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, normalizePageAgentFrontmatter, renderDocsPageStructuredDataJson, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
|
|
17
|
+
import { applySidebarFolderIndexBehavior, buildPageOpenGraph, buildPageTwitter, normalizePageAgentFrontmatter, renderDocsPageStructuredDataJson, resolveChangelogConfig, resolveDocsAnalyticsConfig, resolveDocsAudienceMdxContent, resolveDocsMetadataBaseUrl, resolveDocsSitemapPageLastmod, resolvePageSidebarFolderIndexBehavior, toDocsMarkdownUrl } from "@farming-labs/docs";
|
|
18
|
+
import { readDocsSitemapManifest } from "@farming-labs/docs/runtime";
|
|
18
19
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
20
|
|
|
20
21
|
//#region src/docs-layout.tsx
|
|
21
22
|
function getNextAppDir(root) {
|
|
22
|
-
if (fs.existsSync(
|
|
23
|
+
if (fs.existsSync(
|
|
24
|
+
/* turbopackIgnore: true */
|
|
25
|
+
path.join(
|
|
26
|
+
/* turbopackIgnore: true */
|
|
27
|
+
root,
|
|
28
|
+
"src",
|
|
29
|
+
"app"
|
|
30
|
+
)
|
|
31
|
+
)) return "src/app";
|
|
23
32
|
return "app";
|
|
24
33
|
}
|
|
25
34
|
function withStableReactKey(node, key) {
|
|
@@ -33,7 +42,11 @@ function resolveIcon(iconKey, registry) {
|
|
|
33
42
|
/** Read frontmatter from a page.mdx file. */
|
|
34
43
|
function readFrontmatter(filePath) {
|
|
35
44
|
try {
|
|
36
|
-
const { data } = matter(fs.readFileSync(
|
|
45
|
+
const { data } = matter(fs.readFileSync(
|
|
46
|
+
/* turbopackIgnore: true */
|
|
47
|
+
filePath,
|
|
48
|
+
"utf-8"
|
|
49
|
+
));
|
|
37
50
|
return data;
|
|
38
51
|
} catch {
|
|
39
52
|
return {};
|
|
@@ -69,15 +82,38 @@ function isWithinDir(candidate, target) {
|
|
|
69
82
|
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
70
83
|
}
|
|
71
84
|
function isExcludedDir(dir, excludedDirs) {
|
|
72
|
-
const resolved = path.resolve(
|
|
85
|
+
const resolved = path.resolve(
|
|
86
|
+
/* turbopackIgnore: true */
|
|
87
|
+
dir
|
|
88
|
+
);
|
|
73
89
|
return excludedDirs.some((excluded) => isWithinDir(resolved, excluded));
|
|
74
90
|
}
|
|
75
91
|
function hasChildPages(dir, excludedDirs) {
|
|
76
|
-
if (!fs.existsSync(
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
if (!fs.existsSync(
|
|
93
|
+
/* turbopackIgnore: true */
|
|
94
|
+
dir
|
|
95
|
+
)) return false;
|
|
96
|
+
for (const name of fs.readdirSync(
|
|
97
|
+
/* turbopackIgnore: true */
|
|
98
|
+
dir
|
|
99
|
+
)) {
|
|
100
|
+
const full = path.join(
|
|
101
|
+
/* turbopackIgnore: true */
|
|
102
|
+
dir,
|
|
103
|
+
name
|
|
104
|
+
);
|
|
79
105
|
if (isExcludedDir(full, excludedDirs)) continue;
|
|
80
|
-
if (fs.statSync(
|
|
106
|
+
if (fs.statSync(
|
|
107
|
+
/* turbopackIgnore: true */
|
|
108
|
+
full
|
|
109
|
+
).isDirectory() && fs.existsSync(
|
|
110
|
+
/* turbopackIgnore: true */
|
|
111
|
+
path.join(
|
|
112
|
+
/* turbopackIgnore: true */
|
|
113
|
+
full,
|
|
114
|
+
"page.mdx"
|
|
115
|
+
)
|
|
116
|
+
)) return true;
|
|
81
117
|
}
|
|
82
118
|
return false;
|
|
83
119
|
}
|
|
@@ -101,10 +137,24 @@ function resolveDocsLocaleContext(config, locale) {
|
|
|
101
137
|
function resolveContentDir(localeValue) {
|
|
102
138
|
if (!contentDir) {
|
|
103
139
|
const appDir = getNextAppDir(process.cwd());
|
|
104
|
-
return path.join(
|
|
140
|
+
return path.join(
|
|
141
|
+
/* turbopackIgnore: true */
|
|
142
|
+
process.cwd(),
|
|
143
|
+
appDir,
|
|
144
|
+
entryBase,
|
|
145
|
+
...localeValue ? [localeValue] : []
|
|
146
|
+
);
|
|
105
147
|
}
|
|
106
|
-
const base = path.isAbsolute(contentDir) ? contentDir : path.join(
|
|
107
|
-
|
|
148
|
+
const base = path.isAbsolute(contentDir) ? contentDir : path.join(
|
|
149
|
+
/* turbopackIgnore: true */
|
|
150
|
+
process.cwd(),
|
|
151
|
+
contentDir
|
|
152
|
+
);
|
|
153
|
+
return localeValue ? path.join(
|
|
154
|
+
/* turbopackIgnore: true */
|
|
155
|
+
base,
|
|
156
|
+
localeValue
|
|
157
|
+
) : base;
|
|
108
158
|
}
|
|
109
159
|
if (!i18n) return {
|
|
110
160
|
entryPath: entryBase,
|
|
@@ -141,21 +191,55 @@ function toPublicDocsPath(pathname, ctx) {
|
|
|
141
191
|
function getExcludedDocsDirs(config, ctx) {
|
|
142
192
|
const changelog = resolveChangelogConfig(config.changelog);
|
|
143
193
|
if (!changelog.enabled) return [];
|
|
144
|
-
const dir = path.isAbsolute(changelog.contentDir) ? changelog.contentDir : path.join(
|
|
145
|
-
|
|
194
|
+
const dir = path.isAbsolute(changelog.contentDir) ? changelog.contentDir : path.join(
|
|
195
|
+
/* turbopackIgnore: true */
|
|
196
|
+
ctx.docsDir,
|
|
197
|
+
changelog.contentDir
|
|
198
|
+
);
|
|
199
|
+
return [path.resolve(
|
|
200
|
+
/* turbopackIgnore: true */
|
|
201
|
+
dir
|
|
202
|
+
)];
|
|
146
203
|
}
|
|
147
204
|
function readChangelogTreeEntries(config, ctx) {
|
|
148
205
|
const changelog = resolveChangelogConfig(config.changelog);
|
|
149
206
|
if (!changelog.enabled) return [];
|
|
150
|
-
const changelogDir = path.isAbsolute(changelog.contentDir) ? changelog.contentDir : path.join(
|
|
151
|
-
|
|
207
|
+
const changelogDir = path.isAbsolute(changelog.contentDir) ? changelog.contentDir : path.join(
|
|
208
|
+
/* turbopackIgnore: true */
|
|
209
|
+
ctx.docsDir,
|
|
210
|
+
changelog.contentDir
|
|
211
|
+
);
|
|
212
|
+
if (!fs.existsSync(
|
|
213
|
+
/* turbopackIgnore: true */
|
|
214
|
+
changelogDir
|
|
215
|
+
)) return [];
|
|
152
216
|
const entries = [];
|
|
153
|
-
for (const name of fs.readdirSync(
|
|
217
|
+
for (const name of fs.readdirSync(
|
|
218
|
+
/* turbopackIgnore: true */
|
|
219
|
+
changelogDir
|
|
220
|
+
)) {
|
|
154
221
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(name)) continue;
|
|
155
|
-
const entryDir = path.join(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
222
|
+
const entryDir = path.join(
|
|
223
|
+
/* turbopackIgnore: true */
|
|
224
|
+
changelogDir,
|
|
225
|
+
name
|
|
226
|
+
);
|
|
227
|
+
if (!fs.existsSync(
|
|
228
|
+
/* turbopackIgnore: true */
|
|
229
|
+
entryDir
|
|
230
|
+
) || !fs.statSync(
|
|
231
|
+
/* turbopackIgnore: true */
|
|
232
|
+
entryDir
|
|
233
|
+
).isDirectory()) continue;
|
|
234
|
+
const pagePath = path.join(
|
|
235
|
+
/* turbopackIgnore: true */
|
|
236
|
+
entryDir,
|
|
237
|
+
"page.mdx"
|
|
238
|
+
);
|
|
239
|
+
if (!fs.existsSync(
|
|
240
|
+
/* turbopackIgnore: true */
|
|
241
|
+
pagePath
|
|
242
|
+
)) continue;
|
|
159
243
|
const data = readFrontmatter(pagePath);
|
|
160
244
|
if (data.draft === true) continue;
|
|
161
245
|
entries.push({
|
|
@@ -202,8 +286,19 @@ function buildTree(config, ctx, flat = false) {
|
|
|
202
286
|
const ordering = config.ordering;
|
|
203
287
|
const rootChildren = [];
|
|
204
288
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
205
|
-
if (fs.existsSync(
|
|
206
|
-
|
|
289
|
+
if (fs.existsSync(
|
|
290
|
+
/* turbopackIgnore: true */
|
|
291
|
+
path.join(
|
|
292
|
+
/* turbopackIgnore: true */
|
|
293
|
+
docsDir,
|
|
294
|
+
"page.mdx"
|
|
295
|
+
)
|
|
296
|
+
)) {
|
|
297
|
+
const data = readFrontmatter(path.join(
|
|
298
|
+
/* turbopackIgnore: true */
|
|
299
|
+
docsDir,
|
|
300
|
+
"page.mdx"
|
|
301
|
+
));
|
|
207
302
|
if (data.hidden !== true) rootChildren.push({
|
|
208
303
|
type: "page",
|
|
209
304
|
name: data.title ?? "Documentation",
|
|
@@ -212,11 +307,25 @@ function buildTree(config, ctx, flat = false) {
|
|
|
212
307
|
});
|
|
213
308
|
}
|
|
214
309
|
function buildNode(dir, name, baseSlug, slugOrder) {
|
|
215
|
-
const full = path.join(
|
|
310
|
+
const full = path.join(
|
|
311
|
+
/* turbopackIgnore: true */
|
|
312
|
+
dir,
|
|
313
|
+
name
|
|
314
|
+
);
|
|
216
315
|
if (isExcludedDir(full, excludedDirs)) return null;
|
|
217
|
-
if (!fs.statSync(
|
|
218
|
-
|
|
219
|
-
|
|
316
|
+
if (!fs.statSync(
|
|
317
|
+
/* turbopackIgnore: true */
|
|
318
|
+
full
|
|
319
|
+
).isDirectory()) return null;
|
|
320
|
+
const pagePath = path.join(
|
|
321
|
+
/* turbopackIgnore: true */
|
|
322
|
+
full,
|
|
323
|
+
"page.mdx"
|
|
324
|
+
);
|
|
325
|
+
if (!fs.existsSync(
|
|
326
|
+
/* turbopackIgnore: true */
|
|
327
|
+
pagePath
|
|
328
|
+
)) return null;
|
|
220
329
|
const data = readFrontmatter(pagePath);
|
|
221
330
|
const slug = [...baseSlug, name];
|
|
222
331
|
const url = publicDocsRoute(ctx, slug);
|
|
@@ -265,20 +374,34 @@ function buildTree(config, ctx, flat = false) {
|
|
|
265
374
|
};
|
|
266
375
|
}
|
|
267
376
|
function scanDir(dir, baseSlug, slugOrder) {
|
|
268
|
-
if (!fs.existsSync(
|
|
269
|
-
|
|
377
|
+
if (!fs.existsSync(
|
|
378
|
+
/* turbopackIgnore: true */
|
|
379
|
+
dir
|
|
380
|
+
)) return [];
|
|
381
|
+
const entries = fs.readdirSync(
|
|
382
|
+
/* turbopackIgnore: true */
|
|
383
|
+
dir
|
|
384
|
+
).sort();
|
|
270
385
|
if (slugOrder) {
|
|
271
386
|
const nodes = [];
|
|
272
387
|
const slugMap = /* @__PURE__ */ new Map();
|
|
273
388
|
for (const item of slugOrder) slugMap.set(item.slug, item);
|
|
274
389
|
for (const item of slugOrder) {
|
|
275
390
|
if (!entries.includes(item.slug)) continue;
|
|
276
|
-
if (isExcludedDir(path.join(
|
|
391
|
+
if (isExcludedDir(path.join(
|
|
392
|
+
/* turbopackIgnore: true */
|
|
393
|
+
dir,
|
|
394
|
+
item.slug
|
|
395
|
+
), excludedDirs)) continue;
|
|
277
396
|
const node = buildNode(dir, item.slug, baseSlug, item.children);
|
|
278
397
|
if (node) nodes.push(node);
|
|
279
398
|
}
|
|
280
399
|
for (const name of entries) {
|
|
281
|
-
if (isExcludedDir(path.join(
|
|
400
|
+
if (isExcludedDir(path.join(
|
|
401
|
+
/* turbopackIgnore: true */
|
|
402
|
+
dir,
|
|
403
|
+
name
|
|
404
|
+
), excludedDirs)) continue;
|
|
282
405
|
if (slugMap.has(name)) continue;
|
|
283
406
|
const node = buildNode(dir, name, baseSlug);
|
|
284
407
|
if (node) nodes.push(node);
|
|
@@ -288,11 +411,25 @@ function buildTree(config, ctx, flat = false) {
|
|
|
288
411
|
if (ordering === "numeric") {
|
|
289
412
|
const nodes = [];
|
|
290
413
|
for (const name of entries) {
|
|
291
|
-
const full = path.join(
|
|
414
|
+
const full = path.join(
|
|
415
|
+
/* turbopackIgnore: true */
|
|
416
|
+
dir,
|
|
417
|
+
name
|
|
418
|
+
);
|
|
292
419
|
if (isExcludedDir(full, excludedDirs)) continue;
|
|
293
|
-
if (!fs.statSync(
|
|
294
|
-
|
|
295
|
-
|
|
420
|
+
if (!fs.statSync(
|
|
421
|
+
/* turbopackIgnore: true */
|
|
422
|
+
full
|
|
423
|
+
).isDirectory()) continue;
|
|
424
|
+
const pagePath = path.join(
|
|
425
|
+
/* turbopackIgnore: true */
|
|
426
|
+
full,
|
|
427
|
+
"page.mdx"
|
|
428
|
+
);
|
|
429
|
+
if (!fs.existsSync(
|
|
430
|
+
/* turbopackIgnore: true */
|
|
431
|
+
pagePath
|
|
432
|
+
)) continue;
|
|
296
433
|
const data = readFrontmatter(pagePath);
|
|
297
434
|
const order = typeof data.order === "number" ? data.order : Infinity;
|
|
298
435
|
const node = buildNode(dir, name, baseSlug);
|
|
@@ -309,7 +446,11 @@ function buildTree(config, ctx, flat = false) {
|
|
|
309
446
|
}
|
|
310
447
|
const nodes = [];
|
|
311
448
|
for (const name of entries) {
|
|
312
|
-
if (isExcludedDir(path.join(
|
|
449
|
+
if (isExcludedDir(path.join(
|
|
450
|
+
/* turbopackIgnore: true */
|
|
451
|
+
dir,
|
|
452
|
+
name
|
|
453
|
+
), excludedDirs)) continue;
|
|
313
454
|
const node = buildNode(dir, name, baseSlug);
|
|
314
455
|
if (node) nodes.push(node);
|
|
315
456
|
}
|
|
@@ -355,7 +496,10 @@ function localizeTreeUrls(tree, locale) {
|
|
|
355
496
|
* Scan all page.mdx files under the docs entry directory and build
|
|
356
497
|
* a map of URL pathname → formatted last-modified date string.
|
|
357
498
|
*/
|
|
358
|
-
function
|
|
499
|
+
function resolveManifestLastmod(manifest, ctx, url) {
|
|
500
|
+
return (ctx.locale ? resolveDocsSitemapPageLastmod(manifest, `${url}?lang=${encodeURIComponent(ctx.locale)}`) : void 0) ?? resolveDocsSitemapPageLastmod(manifest, url);
|
|
501
|
+
}
|
|
502
|
+
function buildLastModifiedMap(config, ctx, manifest) {
|
|
359
503
|
const docsDir = ctx.docsDir;
|
|
360
504
|
const map = {};
|
|
361
505
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
@@ -367,16 +511,40 @@ function buildLastModifiedMap(config, ctx) {
|
|
|
367
511
|
});
|
|
368
512
|
}
|
|
369
513
|
function scan(dir, slugParts) {
|
|
370
|
-
if (!fs.existsSync(
|
|
514
|
+
if (!fs.existsSync(
|
|
515
|
+
/* turbopackIgnore: true */
|
|
516
|
+
dir
|
|
517
|
+
)) return;
|
|
371
518
|
if (isExcludedDir(dir, excludedDirs)) return;
|
|
372
|
-
const pagePath = path.join(
|
|
373
|
-
|
|
519
|
+
const pagePath = path.join(
|
|
520
|
+
/* turbopackIgnore: true */
|
|
521
|
+
dir,
|
|
522
|
+
"page.mdx"
|
|
523
|
+
);
|
|
524
|
+
if (fs.existsSync(
|
|
525
|
+
/* turbopackIgnore: true */
|
|
526
|
+
pagePath
|
|
527
|
+
)) {
|
|
374
528
|
const url = publicDocsRoute(ctx, slugParts);
|
|
375
|
-
|
|
529
|
+
const manifestLastmod = resolveManifestLastmod(manifest, ctx, url);
|
|
530
|
+
map[url] = formatDate(manifestLastmod ? /* @__PURE__ */ new Date(`${manifestLastmod}T00:00:00`) : fs.statSync(
|
|
531
|
+
/* turbopackIgnore: true */
|
|
532
|
+
pagePath
|
|
533
|
+
).mtime);
|
|
376
534
|
}
|
|
377
|
-
for (const name of fs.readdirSync(
|
|
378
|
-
|
|
379
|
-
|
|
535
|
+
for (const name of fs.readdirSync(
|
|
536
|
+
/* turbopackIgnore: true */
|
|
537
|
+
dir
|
|
538
|
+
)) {
|
|
539
|
+
const full = path.join(
|
|
540
|
+
/* turbopackIgnore: true */
|
|
541
|
+
dir,
|
|
542
|
+
name
|
|
543
|
+
);
|
|
544
|
+
if (fs.statSync(
|
|
545
|
+
/* turbopackIgnore: true */
|
|
546
|
+
full
|
|
547
|
+
).isDirectory()) scan(full, [...slugParts, name]);
|
|
380
548
|
}
|
|
381
549
|
}
|
|
382
550
|
scan(docsDir, []);
|
|
@@ -391,19 +559,39 @@ function buildDescriptionMap(config, ctx) {
|
|
|
391
559
|
const map = {};
|
|
392
560
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
393
561
|
function scan(dir, slugParts) {
|
|
394
|
-
if (!fs.existsSync(
|
|
562
|
+
if (!fs.existsSync(
|
|
563
|
+
/* turbopackIgnore: true */
|
|
564
|
+
dir
|
|
565
|
+
)) return;
|
|
395
566
|
if (isExcludedDir(dir, excludedDirs)) return;
|
|
396
|
-
const pagePath = path.join(
|
|
397
|
-
|
|
567
|
+
const pagePath = path.join(
|
|
568
|
+
/* turbopackIgnore: true */
|
|
569
|
+
dir,
|
|
570
|
+
"page.mdx"
|
|
571
|
+
);
|
|
572
|
+
if (fs.existsSync(
|
|
573
|
+
/* turbopackIgnore: true */
|
|
574
|
+
pagePath
|
|
575
|
+
)) {
|
|
398
576
|
const desc = readFrontmatter(pagePath).description;
|
|
399
577
|
if (desc) {
|
|
400
578
|
const url = publicDocsRoute(ctx, slugParts);
|
|
401
579
|
map[url] = desc;
|
|
402
580
|
}
|
|
403
581
|
}
|
|
404
|
-
for (const name of fs.readdirSync(
|
|
405
|
-
|
|
406
|
-
|
|
582
|
+
for (const name of fs.readdirSync(
|
|
583
|
+
/* turbopackIgnore: true */
|
|
584
|
+
dir
|
|
585
|
+
)) {
|
|
586
|
+
const full = path.join(
|
|
587
|
+
/* turbopackIgnore: true */
|
|
588
|
+
dir,
|
|
589
|
+
name
|
|
590
|
+
);
|
|
591
|
+
if (fs.statSync(
|
|
592
|
+
/* turbopackIgnore: true */
|
|
593
|
+
full
|
|
594
|
+
).isDirectory()) scan(full, [...slugParts, name]);
|
|
407
595
|
}
|
|
408
596
|
}
|
|
409
597
|
scan(docsDir, []);
|
|
@@ -418,17 +606,34 @@ function buildGeneratedTitleMap(config, ctx) {
|
|
|
418
606
|
const map = {};
|
|
419
607
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
420
608
|
function scan(dir, slugParts) {
|
|
421
|
-
if (!fs.existsSync(
|
|
609
|
+
if (!fs.existsSync(
|
|
610
|
+
/* turbopackIgnore: true */
|
|
611
|
+
dir
|
|
612
|
+
)) return;
|
|
422
613
|
if (isExcludedDir(dir, excludedDirs)) return;
|
|
423
614
|
const pagePath = findDocsPageFile(dir);
|
|
424
615
|
if (pagePath) {
|
|
425
|
-
const source = fs.readFileSync(
|
|
616
|
+
const source = fs.readFileSync(
|
|
617
|
+
/* turbopackIgnore: true */
|
|
618
|
+
pagePath,
|
|
619
|
+
"utf-8"
|
|
620
|
+
);
|
|
426
621
|
const { data } = matter(source);
|
|
427
622
|
if (typeof data.title === "string" && !hasAuthoredPageTitle(source)) map[publicDocsRoute(ctx, slugParts)] = data.title;
|
|
428
623
|
}
|
|
429
|
-
for (const name of fs.readdirSync(
|
|
430
|
-
|
|
431
|
-
|
|
624
|
+
for (const name of fs.readdirSync(
|
|
625
|
+
/* turbopackIgnore: true */
|
|
626
|
+
dir
|
|
627
|
+
)) {
|
|
628
|
+
const full = path.join(
|
|
629
|
+
/* turbopackIgnore: true */
|
|
630
|
+
dir,
|
|
631
|
+
name
|
|
632
|
+
);
|
|
633
|
+
if (fs.statSync(
|
|
634
|
+
/* turbopackIgnore: true */
|
|
635
|
+
full
|
|
636
|
+
).isDirectory()) scan(full, [...slugParts, name]);
|
|
432
637
|
}
|
|
433
638
|
}
|
|
434
639
|
scan(docsDir, []);
|
|
@@ -439,56 +644,108 @@ function buildReadingTimeMap(config, ctx, options) {
|
|
|
439
644
|
const map = {};
|
|
440
645
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
441
646
|
function scan(dir, slugParts) {
|
|
442
|
-
if (!fs.existsSync(
|
|
647
|
+
if (!fs.existsSync(
|
|
648
|
+
/* turbopackIgnore: true */
|
|
649
|
+
dir
|
|
650
|
+
)) return;
|
|
443
651
|
if (isExcludedDir(dir, excludedDirs)) return;
|
|
444
|
-
const pagePath = path.join(
|
|
445
|
-
|
|
446
|
-
|
|
652
|
+
const pagePath = path.join(
|
|
653
|
+
/* turbopackIgnore: true */
|
|
654
|
+
dir,
|
|
655
|
+
"page.mdx"
|
|
656
|
+
);
|
|
657
|
+
if (fs.existsSync(
|
|
658
|
+
/* turbopackIgnore: true */
|
|
659
|
+
pagePath
|
|
660
|
+
)) {
|
|
661
|
+
const { data, content } = matter(fs.readFileSync(
|
|
662
|
+
/* turbopackIgnore: true */
|
|
663
|
+
pagePath,
|
|
664
|
+
"utf-8"
|
|
665
|
+
));
|
|
447
666
|
const minutes = resolvePageReadingTime(data, resolveDocsAudienceMdxContent(content, "human"), options);
|
|
448
667
|
if (typeof minutes === "number") {
|
|
449
668
|
const url = publicDocsRoute(ctx, slugParts);
|
|
450
669
|
map[url] = minutes;
|
|
451
670
|
}
|
|
452
671
|
}
|
|
453
|
-
for (const name of fs.readdirSync(
|
|
454
|
-
|
|
455
|
-
|
|
672
|
+
for (const name of fs.readdirSync(
|
|
673
|
+
/* turbopackIgnore: true */
|
|
674
|
+
dir
|
|
675
|
+
)) {
|
|
676
|
+
const full = path.join(
|
|
677
|
+
/* turbopackIgnore: true */
|
|
678
|
+
dir,
|
|
679
|
+
name
|
|
680
|
+
);
|
|
681
|
+
if (fs.statSync(
|
|
682
|
+
/* turbopackIgnore: true */
|
|
683
|
+
full
|
|
684
|
+
).isDirectory()) scan(full, [...slugParts, name]);
|
|
456
685
|
}
|
|
457
686
|
}
|
|
458
687
|
scan(docsDir, []);
|
|
459
688
|
return map;
|
|
460
689
|
}
|
|
461
690
|
function findDocsPageFile(dir) {
|
|
462
|
-
return ["page.mdx", "page.md"].map((fileName) => path.join(
|
|
691
|
+
return ["page.mdx", "page.md"].map((fileName) => path.join(
|
|
692
|
+
/* turbopackIgnore: true */
|
|
693
|
+
dir,
|
|
694
|
+
fileName
|
|
695
|
+
)).find((candidate) => fs.existsSync(
|
|
696
|
+
/* turbopackIgnore: true */
|
|
697
|
+
candidate
|
|
698
|
+
));
|
|
463
699
|
}
|
|
464
|
-
function buildStructuredDataMap(config, ctx) {
|
|
700
|
+
function buildStructuredDataMap(config, ctx, manifest) {
|
|
465
701
|
const docsDir = ctx.docsDir;
|
|
466
702
|
const map = {};
|
|
467
703
|
const excludedDirs = getExcludedDocsDirs(config, ctx);
|
|
468
704
|
const baseUrl = resolveDocsMetadataBaseUrl(config);
|
|
469
705
|
function scan(dir, slugParts) {
|
|
470
|
-
if (!fs.existsSync(
|
|
706
|
+
if (!fs.existsSync(
|
|
707
|
+
/* turbopackIgnore: true */
|
|
708
|
+
dir
|
|
709
|
+
)) return;
|
|
471
710
|
if (isExcludedDir(dir, excludedDirs)) return;
|
|
472
711
|
const pagePath = findDocsPageFile(dir);
|
|
473
712
|
if (pagePath) {
|
|
474
|
-
const { data } = matter(fs.readFileSync(
|
|
713
|
+
const { data } = matter(fs.readFileSync(
|
|
714
|
+
/* turbopackIgnore: true */
|
|
715
|
+
pagePath,
|
|
716
|
+
"utf-8"
|
|
717
|
+
));
|
|
475
718
|
const route = publicDocsRoute(ctx, slugParts);
|
|
476
719
|
const title = typeof data.title === "string" ? data.title : slugParts.at(-1)?.replace(/-/g, " ") || "Documentation";
|
|
477
720
|
const description = typeof data.description === "string" ? data.description : void 0;
|
|
478
|
-
const
|
|
721
|
+
const manifestLastmod = resolveManifestLastmod(manifest, ctx, route);
|
|
722
|
+
const dateModified = manifestLastmod ? `${manifestLastmod}T00:00:00.000Z` : fs.statSync(
|
|
723
|
+
/* turbopackIgnore: true */
|
|
724
|
+
pagePath
|
|
725
|
+
).mtime.toISOString();
|
|
479
726
|
map[route] = renderDocsPageStructuredDataJson({
|
|
480
727
|
title,
|
|
481
728
|
description,
|
|
482
729
|
url: withLangInUrl(route, ctx.locale),
|
|
483
730
|
baseUrl,
|
|
484
731
|
entry: ctx.entryPath,
|
|
485
|
-
dateModified
|
|
732
|
+
dateModified,
|
|
486
733
|
agent: normalizePageAgentFrontmatter(data.agent)
|
|
487
734
|
});
|
|
488
735
|
}
|
|
489
|
-
for (const name of fs.readdirSync(
|
|
490
|
-
|
|
491
|
-
|
|
736
|
+
for (const name of fs.readdirSync(
|
|
737
|
+
/* turbopackIgnore: true */
|
|
738
|
+
dir
|
|
739
|
+
)) {
|
|
740
|
+
const full = path.join(
|
|
741
|
+
/* turbopackIgnore: true */
|
|
742
|
+
dir,
|
|
743
|
+
name
|
|
744
|
+
);
|
|
745
|
+
if (fs.statSync(
|
|
746
|
+
/* turbopackIgnore: true */
|
|
747
|
+
full
|
|
748
|
+
).isDirectory()) scan(full, [...slugParts, name]);
|
|
492
749
|
}
|
|
493
750
|
}
|
|
494
751
|
scan(docsDir, []);
|
|
@@ -687,6 +944,7 @@ function createDocsLayout(config, options) {
|
|
|
687
944
|
const tocStyle = tocConfig?.style;
|
|
688
945
|
const analyticsEnabled = resolveDocsAnalyticsConfig(config.analytics).enabled;
|
|
689
946
|
const localeContext = resolveDocsLocaleContext(config, options?.locale);
|
|
947
|
+
const sitemapManifest = readDocsSitemapManifest(process.cwd(), config.sitemap);
|
|
690
948
|
const i18n = resolveDocsI18nConfig(getDocsI18n(config));
|
|
691
949
|
const activeLocale = localeContext.locale ?? i18n?.defaultLocale;
|
|
692
950
|
const docsApiUrl = withLangInUrl("/api/docs", activeLocale);
|
|
@@ -756,7 +1014,7 @@ function createDocsLayout(config, options) {
|
|
|
756
1014
|
aiModels = rawModelConfig.models ?? aiModels;
|
|
757
1015
|
aiDefaultModelId = rawModelConfig.defaultModel ?? rawModelConfig.models?.[0]?.id ?? aiDefaultModelId;
|
|
758
1016
|
}
|
|
759
|
-
const lastModifiedMap = buildLastModifiedMap(config, localeContext);
|
|
1017
|
+
const lastModifiedMap = buildLastModifiedMap(config, localeContext, sitemapManifest);
|
|
760
1018
|
const descriptionMap = buildDescriptionMap(config, localeContext);
|
|
761
1019
|
const generatedTitleMap = config.theme?.name === "shadcn" ? buildGeneratedTitleMap(config, localeContext) : {};
|
|
762
1020
|
const readingTimeMap = buildReadingTimeMap(config, localeContext, {
|
|
@@ -764,7 +1022,7 @@ function createDocsLayout(config, options) {
|
|
|
764
1022
|
wordsPerMinute: readingTimeWordsPerMinute,
|
|
765
1023
|
includeCode: readingTimeIncludeCode
|
|
766
1024
|
});
|
|
767
|
-
const structuredDataMap = buildStructuredDataMap(config, localeContext);
|
|
1025
|
+
const structuredDataMap = buildStructuredDataMap(config, localeContext, sitemapManifest);
|
|
768
1026
|
const readingTimeEnabled = readingTimeEnabledByDefault || Object.keys(readingTimeMap).length > 0;
|
|
769
1027
|
return function DocsLayoutWrapper({ children }) {
|
|
770
1028
|
const tree = applySidebarFolderIndexBehavior(buildTree(config, localeContext, !!sidebarFlat), {
|
package/dist/get-app-dir.mjs
CHANGED
|
@@ -8,7 +8,15 @@ import path from "node:path";
|
|
|
8
8
|
* Use this so docs layout and API resolve MDX content in the same place the CLI generated it.
|
|
9
9
|
*/
|
|
10
10
|
function getNextAppDir(root) {
|
|
11
|
-
if (fs.existsSync(
|
|
11
|
+
if (fs.existsSync(
|
|
12
|
+
/* turbopackIgnore: true */
|
|
13
|
+
path.join(
|
|
14
|
+
/* turbopackIgnore: true */
|
|
15
|
+
root,
|
|
16
|
+
"src",
|
|
17
|
+
"app"
|
|
18
|
+
)
|
|
19
|
+
)) return "src/app";
|
|
12
20
|
return "app";
|
|
13
21
|
}
|
|
14
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.118",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"tsdown": "^0.20.3",
|
|
162
162
|
"typescript": "^5.9.3",
|
|
163
163
|
"vitest": "^4.1.8",
|
|
164
|
-
"@farming-labs/docs": "0.2.
|
|
164
|
+
"@farming-labs/docs": "0.2.118"
|
|
165
165
|
},
|
|
166
166
|
"peerDependencies": {
|
|
167
167
|
"@farming-labs/docs": ">=0.0.1",
|