@rspress/core 2.0.0-beta.34 → 2.0.0-beta.35
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/{4~101.js → 5~101.js} +16 -16
- package/dist/_private/react/index.js +2 -0
- package/dist/_private/react/reconciler.js +169 -0
- package/dist/_private/react/render.js +105 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +86 -0
- package/dist/index.js +433 -111
- package/dist/loader.d.ts +10 -2
- package/dist/loader.js +4 -3
- package/dist/processor.d.ts +10 -2
- package/dist/processor.js +3726 -34
- package/dist/renderPageWorker.js +2 -1
- package/dist/runtime/ssrMdServerEntry.d.ts +5 -0
- package/dist/runtime/ssrMdServerEntry.js +38 -0
- package/meta-json-schema.json +45 -3
- package/package.json +19 -12
- /package/dist/{4~335.js → 5~335.js} +0 -0
- /package/dist/{4~395.js → 5~395.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
65
65
|
}, []));
|
|
66
66
|
})();
|
|
67
67
|
(()=>{
|
|
68
|
-
__webpack_require__.u = (chunkId)=>"
|
|
68
|
+
__webpack_require__.u = (chunkId)=>"5~" + chunkId + ".js";
|
|
69
69
|
})();
|
|
70
70
|
(()=>{
|
|
71
71
|
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
@@ -211,7 +211,7 @@ function normalizePath(id) {
|
|
|
211
211
|
return external_node_path_["default"].posix.normalize(isWindows ? slash(id) : id);
|
|
212
212
|
}
|
|
213
213
|
var external_node_url_ = __webpack_require__("node:url");
|
|
214
|
-
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.
|
|
214
|
+
var package_namespaceObject = JSON.parse('{"rE":"2.0.0-beta.35"}');
|
|
215
215
|
const RSPRESS_VERSION = package_namespaceObject.rE;
|
|
216
216
|
const isProduction = ()=>'production' === process.env.NODE_ENV;
|
|
217
217
|
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
@@ -229,6 +229,7 @@ const TEMPLATE_PATH = external_node_path_["default"].join(PACKAGE_ROOT, 'index.h
|
|
|
229
229
|
const CSR_CLIENT_ENTRY = external_node_path_["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
|
|
230
230
|
const SSR_CLIENT_ENTRY = external_node_path_["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
|
|
231
231
|
const SSR_SERVER_ENTRY = external_node_path_["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrServerEntry.js');
|
|
232
|
+
const SSG_MD_SERVER_ENTRY = external_node_path_["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrMdServerEntry.js');
|
|
232
233
|
const OUTPUT_DIR = 'doc_build';
|
|
233
234
|
const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
|
|
234
235
|
const HEAD_MARKER = '<!--<?- HEAD ?>-->';
|
|
@@ -237,6 +238,8 @@ const DEFAULT_TITLE = 'Rspress';
|
|
|
237
238
|
const PUBLIC_DIR = 'public';
|
|
238
239
|
const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
|
|
239
240
|
const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
|
|
241
|
+
const NODE_SSG_MD_BUNDLE_FOLDER = '__ssg_md__';
|
|
242
|
+
const NODE_SSG_MD_BUNDLE_NAME = 'rspress-ssg-md-entry.cjs';
|
|
240
243
|
const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
|
|
241
244
|
const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
|
|
242
245
|
return [
|
|
@@ -447,6 +450,15 @@ ${routeMeta.map((route, index)=>{
|
|
|
447
450
|
getRoutePageByRoutePath(routePath) {
|
|
448
451
|
return this.routeData.get(routePath);
|
|
449
452
|
}
|
|
453
|
+
getDocsDir() {
|
|
454
|
+
return this.#scanDir;
|
|
455
|
+
}
|
|
456
|
+
getLangs() {
|
|
457
|
+
return this.#langs;
|
|
458
|
+
}
|
|
459
|
+
getDefaultLang() {
|
|
460
|
+
return this.#defaultLang;
|
|
461
|
+
}
|
|
450
462
|
}
|
|
451
463
|
class RoutePage {
|
|
452
464
|
routeMeta;
|
|
@@ -519,7 +531,7 @@ async function utils_readJson(path) {
|
|
|
519
531
|
async function extractInfoFromFrontmatterWithAbsolutePath(absolutePath, rootDir) {
|
|
520
532
|
const fileHandle = await node_fs_promises.open(absolutePath, 'r');
|
|
521
533
|
try {
|
|
522
|
-
const buffer = Buffer.alloc(
|
|
534
|
+
const buffer = Buffer.alloc(2048);
|
|
523
535
|
let content = '';
|
|
524
536
|
let bytesRead = 0;
|
|
525
537
|
let hasFrontmatter = false;
|
|
@@ -542,7 +554,7 @@ async function extractInfoFromFrontmatterWithAbsolutePath(absolutePath, rootDir)
|
|
|
542
554
|
} else hasFrontmatter = false;
|
|
543
555
|
if (!h1Match) {
|
|
544
556
|
const searchStart = hasFrontmatter && frontmatterEnd > -1 ? frontmatterEnd : 0;
|
|
545
|
-
const h1RegExp = /^#\s+(
|
|
557
|
+
const h1RegExp = /^#\s+(.*?)\n$/m;
|
|
546
558
|
h1Match = content.slice(searchStart).match(h1RegExp);
|
|
547
559
|
}
|
|
548
560
|
if (hasFrontmatter && frontmatterEnd > -1 && h1Match) break;
|
|
@@ -553,17 +565,23 @@ async function extractInfoFromFrontmatterWithAbsolutePath(absolutePath, rootDir)
|
|
|
553
565
|
const { frontmatter: fm } = loadFrontMatter(content, absolutePath, rootDir);
|
|
554
566
|
frontmatter = fm;
|
|
555
567
|
}
|
|
568
|
+
if (!h1Match) {
|
|
569
|
+
const h1RegExp = /^#\s+(.*)$/m;
|
|
570
|
+
h1Match = content.match(h1RegExp);
|
|
571
|
+
}
|
|
556
572
|
const fileNameWithoutExt = external_node_path_["default"].basename(absolutePath, external_node_path_["default"].extname(absolutePath));
|
|
557
573
|
return {
|
|
558
574
|
title: extractTextAndId(frontmatter.title || h1Match?.[1] || fileNameWithoutExt)[0],
|
|
559
575
|
overviewHeaders: frontmatter.overviewHeaders,
|
|
560
|
-
context: frontmatter.context
|
|
576
|
+
context: frontmatter.context,
|
|
577
|
+
tag: frontmatter.tag,
|
|
578
|
+
description: frontmatter.description
|
|
561
579
|
};
|
|
562
580
|
} finally{
|
|
563
581
|
await fileHandle.close();
|
|
564
582
|
}
|
|
565
583
|
}
|
|
566
|
-
function
|
|
584
|
+
function getFileKey(realPath, docsDir) {
|
|
567
585
|
return realPath ? (0, shared_.slash)((0, external_node_path_.relative)(docsDir, realPath).replace((0, external_node_path_.extname)(realPath), '')) : '';
|
|
568
586
|
}
|
|
569
587
|
async function fsDirToMetaItems(workDir, extensions) {
|
|
@@ -593,83 +611,15 @@ async function fsDirToMetaItems(workDir, extensions) {
|
|
|
593
611
|
}))).filter(Boolean);
|
|
594
612
|
return sideMeta;
|
|
595
613
|
}
|
|
596
|
-
async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet
|
|
614
|
+
async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
597
615
|
if ('string' == typeof metaItem) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions, mdFileSet);
|
|
598
616
|
const { type } = metaItem;
|
|
599
617
|
if ('file' === type) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions, mdFileSet);
|
|
600
|
-
if ('dir' === type)
|
|
601
|
-
|
|
602
|
-
const dirAbsolutePath = (0, external_node_path_.join)(workDir, name);
|
|
603
|
-
const dirMetaJsonPath = (0, external_node_path_.join)(dirAbsolutePath, '_meta.json');
|
|
604
|
-
const isMetaJsonExist = await utils_pathExists(dirMetaJsonPath);
|
|
605
|
-
let dirMetaJson = [];
|
|
606
|
-
if (isMetaJsonExist) {
|
|
607
|
-
metaFileSet.add(dirMetaJsonPath);
|
|
608
|
-
dirMetaJson = await utils_readJson(dirMetaJsonPath);
|
|
609
|
-
} else dirMetaJson = await fsDirToMetaItems(dirAbsolutePath, extensions);
|
|
610
|
-
async function getItems(withoutIndex = false) {
|
|
611
|
-
const items = await Promise.all((withoutIndex ? dirMetaJson.filter((i)=>{
|
|
612
|
-
let name;
|
|
613
|
-
if ('object' == typeof i && 'type' in i && 'file' === i.type) name = i.name;
|
|
614
|
-
else {
|
|
615
|
-
if ('string' != typeof i) return true;
|
|
616
|
-
name = i;
|
|
617
|
-
}
|
|
618
|
-
return 'index.md' !== name && 'index.mdx' !== i && 'index' !== i;
|
|
619
|
-
}) : dirMetaJson).map((item)=>metaItemToSidebarItem(item, dirAbsolutePath, docsDir, extensions, metaFileSet, mdFileSet)));
|
|
620
|
-
return items;
|
|
621
|
-
}
|
|
622
|
-
try {
|
|
623
|
-
const sameNameFile = await metaFileItemToSidebarItem(name, workDir, docsDir, extensions, mdFileSet);
|
|
624
|
-
const { link, text, _fileKey, context, overviewHeaders, tag } = sameNameFile;
|
|
625
|
-
return {
|
|
626
|
-
text: label || text || name,
|
|
627
|
-
collapsible,
|
|
628
|
-
collapsed,
|
|
629
|
-
items: await getItems(),
|
|
630
|
-
link,
|
|
631
|
-
tag: metaJsonTag || tag,
|
|
632
|
-
overviewHeaders: metaJsonOverviewHeaders || overviewHeaders,
|
|
633
|
-
context: metaJsonContext || context,
|
|
634
|
-
_fileKey
|
|
635
|
-
};
|
|
636
|
-
} catch (e) {
|
|
637
|
-
logger.debug(e);
|
|
638
|
-
const isIndexInMetaJsonIndex = dirMetaJson.find((i)=>{
|
|
639
|
-
if ('string' == typeof i) return 'index' === i.replace((0, external_node_path_.extname)(i), '');
|
|
640
|
-
return false;
|
|
641
|
-
});
|
|
642
|
-
const isIndexFileExists = await utils_pathExists((0, external_node_path_.join)(dirAbsolutePath, 'index.mdx')) || await utils_pathExists((0, external_node_path_.join)(dirAbsolutePath, 'index.md'));
|
|
643
|
-
if (isMetaJsonExist && isIndexInMetaJsonIndex || !isIndexFileExists) return {
|
|
644
|
-
text: label || name,
|
|
645
|
-
collapsible,
|
|
646
|
-
collapsed,
|
|
647
|
-
items: await getItems(),
|
|
648
|
-
link: void 0,
|
|
649
|
-
tag: metaJsonTag,
|
|
650
|
-
overviewHeaders: metaJsonOverviewHeaders,
|
|
651
|
-
context: metaJsonContext,
|
|
652
|
-
_fileKey: getHmrFileKey(dirAbsolutePath, docsDir)
|
|
653
|
-
};
|
|
654
|
-
{
|
|
655
|
-
const indexFile = await metaFileItemToSidebarItem('index', dirAbsolutePath, docsDir, extensions, mdFileSet);
|
|
656
|
-
const { link, text, _fileKey, context, overviewHeaders, tag } = indexFile;
|
|
657
|
-
return {
|
|
658
|
-
text: label || text || name,
|
|
659
|
-
collapsible,
|
|
660
|
-
collapsed,
|
|
661
|
-
items: await getItems(!isFirstDir),
|
|
662
|
-
link,
|
|
663
|
-
tag: metaJsonTag || tag,
|
|
664
|
-
overviewHeaders: metaJsonOverviewHeaders || overviewHeaders,
|
|
665
|
-
context: metaJsonContext || context,
|
|
666
|
-
_fileKey
|
|
667
|
-
};
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
618
|
+
if ('dir' === type) return metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet, false);
|
|
619
|
+
if ('dir-section-header' === type) return metaDirSectionHeaderItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet);
|
|
671
620
|
if ('custom-link' === type) return metaCustomLinkItemToSidebarItem(metaItem, workDir, docsDir);
|
|
672
|
-
if ('divider' === type
|
|
621
|
+
if ('divider' === type) return metaDividerToSidebarItem(metaItem);
|
|
622
|
+
if ('section-header' === type) return metaSectionHeaderToSidebarItem(metaItem);
|
|
673
623
|
throw new Error(`Unknown meta item type: ${metaItem.type}, please check it in "${(0, external_node_path_.join)(workDir, '_meta.json')}".`);
|
|
674
624
|
}
|
|
675
625
|
async function detectFilePath(absolutePath, extensions) {
|
|
@@ -703,11 +653,97 @@ async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensio
|
|
|
703
653
|
return {
|
|
704
654
|
text: title,
|
|
705
655
|
link,
|
|
706
|
-
tag,
|
|
656
|
+
tag: info.tag || tag,
|
|
707
657
|
overviewHeaders: info.overviewHeaders || overviewHeaders,
|
|
708
658
|
context: info.context || context,
|
|
709
|
-
_fileKey:
|
|
659
|
+
_fileKey: getFileKey(absolutePathWithExt, docsDir)
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
async function metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet, forceIndexFileAsItem) {
|
|
663
|
+
const { name, label, collapsible, collapsed, tag: metaJsonTag, context: metaJsonContext, overviewHeaders: metaJsonOverviewHeaders } = metaItem;
|
|
664
|
+
const dirAbsolutePath = (0, external_node_path_.join)(workDir, name);
|
|
665
|
+
const dirMetaJsonPath = (0, external_node_path_.join)(dirAbsolutePath, '_meta.json');
|
|
666
|
+
const isMetaJsonExist = await utils_pathExists(dirMetaJsonPath);
|
|
667
|
+
let dirMetaJson = [];
|
|
668
|
+
if (isMetaJsonExist) {
|
|
669
|
+
metaFileSet.add(dirMetaJsonPath);
|
|
670
|
+
dirMetaJson = await utils_readJson(dirMetaJsonPath);
|
|
671
|
+
} else dirMetaJson = await fsDirToMetaItems(dirAbsolutePath, extensions);
|
|
672
|
+
async function getItems(withoutIndex = false) {
|
|
673
|
+
const items = await Promise.all((withoutIndex ? dirMetaJson.filter((i)=>{
|
|
674
|
+
let name;
|
|
675
|
+
if ('object' == typeof i && 'type' in i && 'file' === i.type) name = i.name;
|
|
676
|
+
else {
|
|
677
|
+
if ('string' != typeof i) return true;
|
|
678
|
+
name = i;
|
|
679
|
+
}
|
|
680
|
+
return 'index.md' !== name && 'index.mdx' !== i && 'index' !== i;
|
|
681
|
+
}) : dirMetaJson).map((item)=>metaItemToSidebarItem(item, dirAbsolutePath, docsDir, extensions, metaFileSet, mdFileSet)));
|
|
682
|
+
return items.flat();
|
|
683
|
+
}
|
|
684
|
+
try {
|
|
685
|
+
const sameNameFile = await metaFileItemToSidebarItem(name, workDir, docsDir, extensions, mdFileSet);
|
|
686
|
+
const { link, text, _fileKey, context, overviewHeaders, tag } = sameNameFile;
|
|
687
|
+
return {
|
|
688
|
+
text: label || text || name,
|
|
689
|
+
collapsible,
|
|
690
|
+
collapsed,
|
|
691
|
+
items: await getItems(),
|
|
692
|
+
link,
|
|
693
|
+
tag: metaJsonTag || tag,
|
|
694
|
+
overviewHeaders: metaJsonOverviewHeaders || overviewHeaders,
|
|
695
|
+
context: metaJsonContext || context,
|
|
696
|
+
_fileKey
|
|
697
|
+
};
|
|
698
|
+
} catch (e) {
|
|
699
|
+
logger.debug(e);
|
|
700
|
+
const isIndexInMetaJsonIndex = dirMetaJson.find((i)=>{
|
|
701
|
+
if ('string' == typeof i) return 'index' === i.replace((0, external_node_path_.extname)(i), '');
|
|
702
|
+
return false;
|
|
703
|
+
});
|
|
704
|
+
const isIndexFileExists = await utils_pathExists((0, external_node_path_.join)(dirAbsolutePath, 'index.mdx')) || await utils_pathExists((0, external_node_path_.join)(dirAbsolutePath, 'index.md'));
|
|
705
|
+
if (isMetaJsonExist && isIndexInMetaJsonIndex || !isIndexFileExists) return {
|
|
706
|
+
text: label || name,
|
|
707
|
+
collapsible,
|
|
708
|
+
collapsed,
|
|
709
|
+
items: await getItems(),
|
|
710
|
+
overviewHeaders: metaJsonOverviewHeaders,
|
|
711
|
+
context: metaJsonContext,
|
|
712
|
+
_fileKey: getFileKey(dirAbsolutePath, docsDir)
|
|
713
|
+
};
|
|
714
|
+
{
|
|
715
|
+
const indexFile = await metaFileItemToSidebarItem('index', dirAbsolutePath, docsDir, extensions, mdFileSet);
|
|
716
|
+
const { link, text, _fileKey, context, overviewHeaders, tag } = indexFile;
|
|
717
|
+
return {
|
|
718
|
+
text: label || text || name,
|
|
719
|
+
collapsible,
|
|
720
|
+
collapsed,
|
|
721
|
+
items: await getItems(!forceIndexFileAsItem),
|
|
722
|
+
link,
|
|
723
|
+
tag: metaJsonTag || tag,
|
|
724
|
+
overviewHeaders: metaJsonOverviewHeaders || overviewHeaders,
|
|
725
|
+
context: metaJsonContext || context,
|
|
726
|
+
_fileKey
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
async function metaDirSectionHeaderItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
732
|
+
const fakeDirMetaItem = {
|
|
733
|
+
...metaItem,
|
|
734
|
+
type: 'dir'
|
|
735
|
+
};
|
|
736
|
+
const fakeSectionHeaderMetaItem = {
|
|
737
|
+
label: metaItem.label,
|
|
738
|
+
tag: metaItem.tag,
|
|
739
|
+
type: 'section-header'
|
|
710
740
|
};
|
|
741
|
+
const dirSideGroup = await metaDirItemToSidebarItem(fakeDirMetaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet, true);
|
|
742
|
+
const sectionHeaderSideItem = metaSectionHeaderToSidebarItem(fakeSectionHeaderMetaItem);
|
|
743
|
+
return [
|
|
744
|
+
sectionHeaderSideItem,
|
|
745
|
+
...dirSideGroup.items.length >= 1 ? dirSideGroup.items : []
|
|
746
|
+
];
|
|
711
747
|
}
|
|
712
748
|
function metaCustomLinkItemToSidebarItem(metaItem, workDir, docsDir) {
|
|
713
749
|
if ('items' in metaItem && Array.isArray(metaItem.items) && metaItem.items.length > 0) {
|
|
@@ -744,13 +780,12 @@ function metaCustomLinkItemToSidebarItem(metaItem, workDir, docsDir) {
|
|
|
744
780
|
throw new Error(`The custom link "${label}" does not have a link, please check it in "${(0, external_node_path_.join)(workDir, '_meta.json')}".`);
|
|
745
781
|
}
|
|
746
782
|
function metaDividerToSidebarItem(metaItem) {
|
|
747
|
-
const {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
783
|
+
const { dashed } = metaItem;
|
|
784
|
+
return {
|
|
785
|
+
dividerType: dashed ? 'dashed' : 'solid'
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function metaSectionHeaderToSidebarItem(metaItem) {
|
|
754
789
|
const { label, tag } = metaItem;
|
|
755
790
|
return {
|
|
756
791
|
sectionHeaderText: label ?? '',
|
|
@@ -758,7 +793,7 @@ function metaDividerToSidebarItem(metaItem) {
|
|
|
758
793
|
};
|
|
759
794
|
}
|
|
760
795
|
async function scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
|
|
761
|
-
const dir = await
|
|
796
|
+
const dir = await metaDirItemToSidebarItem({
|
|
762
797
|
type: 'dir',
|
|
763
798
|
name: ''
|
|
764
799
|
}, workDir, docsDir, extensions, metaFileSet, mdFileSet, true);
|
|
@@ -1385,10 +1420,8 @@ function normalizeThemeConfig(docConfig) {
|
|
|
1385
1420
|
async function createSiteData(userConfig) {
|
|
1386
1421
|
const tempSearchObj = Object.assign({}, userConfig.search);
|
|
1387
1422
|
if (tempSearchObj) tempSearchObj.searchHooks = void 0;
|
|
1388
|
-
const { base } = userConfig;
|
|
1389
|
-
const normalizedBase = (0, shared_.addTrailingSlash)((0, shared_.addLeadingSlash)(base ?? '/'));
|
|
1390
1423
|
const siteData = {
|
|
1391
|
-
base:
|
|
1424
|
+
base: userConfig.base ?? '/',
|
|
1392
1425
|
title: userConfig?.title || '',
|
|
1393
1426
|
description: userConfig?.description || '',
|
|
1394
1427
|
icon: getIconUrlPath(userConfig?.icon) || '',
|
|
@@ -1838,6 +1871,234 @@ const rsbuildPluginSSG = ({ routeService, config })=>({
|
|
|
1838
1871
|
});
|
|
1839
1872
|
}
|
|
1840
1873
|
});
|
|
1874
|
+
function routePathToMdPath(routePath, base) {
|
|
1875
|
+
let url = routePath;
|
|
1876
|
+
url = (0, shared_.normalizeHref)(url, false);
|
|
1877
|
+
url = url.replace(/\.html$/, '.md');
|
|
1878
|
+
return (0, shared_.withBase)(url, base);
|
|
1879
|
+
}
|
|
1880
|
+
async function generateLlmsTxt(routeGroups, others, navList, title, description, base, routeService) {
|
|
1881
|
+
const lines = [];
|
|
1882
|
+
const summary = `# ${title}${description ? `\n\n> ${description}` : ''}`;
|
|
1883
|
+
async function genH2Part(nav, routes) {
|
|
1884
|
+
const lines = [];
|
|
1885
|
+
const { text } = nav;
|
|
1886
|
+
if (0 === routes.length) return lines;
|
|
1887
|
+
const routeLines = (await Promise.all(routes.map(async (route)=>{
|
|
1888
|
+
const routePage = routeService.getRoutePageByRoutePath(route);
|
|
1889
|
+
const { lang, routePath, absolutePath } = routePage.routeMeta;
|
|
1890
|
+
if ('/' === routePath || routePath === `/${lang}/`) return;
|
|
1891
|
+
const { title, description } = await extractInfoFromFrontmatterWithAbsolutePath(absolutePath, routeService.getDocsDir());
|
|
1892
|
+
return `- [${title}](${routePathToMdPath(routePath, base)})${description ? `: ${description}` : ''}`;
|
|
1893
|
+
}))).filter((i)=>Boolean(i));
|
|
1894
|
+
if (routeLines.length > 0) {
|
|
1895
|
+
const title = text;
|
|
1896
|
+
lines.push(`\n## ${title}\n`);
|
|
1897
|
+
lines.push(...routeLines);
|
|
1898
|
+
}
|
|
1899
|
+
return lines;
|
|
1900
|
+
}
|
|
1901
|
+
const h2Parts = await Promise.all(navList.map(async (nav, i)=>{
|
|
1902
|
+
const routes = routeGroups[i];
|
|
1903
|
+
const h2Part = await genH2Part(nav, routes);
|
|
1904
|
+
return h2Part;
|
|
1905
|
+
}));
|
|
1906
|
+
lines.push(...h2Parts.flat());
|
|
1907
|
+
const otherLines = await genH2Part({
|
|
1908
|
+
text: 'Others'
|
|
1909
|
+
}, others);
|
|
1910
|
+
lines.push(...otherLines);
|
|
1911
|
+
const llmsTxt = `${summary}\n${lines.join('\n')}`;
|
|
1912
|
+
return llmsTxt;
|
|
1913
|
+
}
|
|
1914
|
+
function generateLlmsFullTxt(routeGroups, navList, others, base, mdContents) {
|
|
1915
|
+
const lines = [];
|
|
1916
|
+
for(let i = 0; i < navList.length; i++){
|
|
1917
|
+
const routeGroup = routeGroups[i];
|
|
1918
|
+
if (0 !== routeGroup.length) for (const routePath of routeGroup){
|
|
1919
|
+
lines.push(`---
|
|
1920
|
+
url: ${routePathToMdPath(routePath, base)}
|
|
1921
|
+
---
|
|
1922
|
+
`);
|
|
1923
|
+
lines.push(mdContents.get(routePath) ?? '');
|
|
1924
|
+
lines.push('\n');
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
for (const routePath of others){
|
|
1928
|
+
lines.push(`---
|
|
1929
|
+
url: ${routePathToMdPath(routePath, base)}
|
|
1930
|
+
---
|
|
1931
|
+
`);
|
|
1932
|
+
lines.push(mdContents.get(routePath) ?? '');
|
|
1933
|
+
lines.push('\n');
|
|
1934
|
+
}
|
|
1935
|
+
return lines.join('\n');
|
|
1936
|
+
}
|
|
1937
|
+
async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
1938
|
+
const base = config.base ?? '/';
|
|
1939
|
+
const locales = config.themeConfig?.locales;
|
|
1940
|
+
const isMultiLang = locales && locales.length > 0;
|
|
1941
|
+
const nav = isMultiLang ? locales.filter((i)=>Boolean(i.nav)).map((i)=>({
|
|
1942
|
+
nav: i.nav,
|
|
1943
|
+
lang: i.lang
|
|
1944
|
+
})) : [
|
|
1945
|
+
{
|
|
1946
|
+
nav: config.themeConfig?.nav,
|
|
1947
|
+
lang: config.lang ?? ''
|
|
1948
|
+
}
|
|
1949
|
+
];
|
|
1950
|
+
const sidebars = isMultiLang ? locales.map((i)=>i.sidebar) : [
|
|
1951
|
+
config.themeConfig?.sidebar
|
|
1952
|
+
];
|
|
1953
|
+
const sidebar = sidebars.reduce((prev, curr)=>{
|
|
1954
|
+
Object.assign(prev, curr);
|
|
1955
|
+
return prev;
|
|
1956
|
+
}, {});
|
|
1957
|
+
const noVersionNav = Array.isArray(nav) ? nav.map((i)=>{
|
|
1958
|
+
const nav = i.nav.default || i.nav;
|
|
1959
|
+
const lang = i.lang;
|
|
1960
|
+
return nav.map((i)=>({
|
|
1961
|
+
...i,
|
|
1962
|
+
lang
|
|
1963
|
+
}));
|
|
1964
|
+
}).flat().filter((i)=>i.activeMatch || i.link) : [];
|
|
1965
|
+
const defaultLang = routeService.getDefaultLang();
|
|
1966
|
+
await Promise.all(routeService.getLangs().map(async (lang)=>{
|
|
1967
|
+
const navList = noVersionNav.filter((i)=>i.lang === lang);
|
|
1968
|
+
const routeGroups = new Array(navList.length).fill(0).map(()=>[]);
|
|
1969
|
+
const others = [];
|
|
1970
|
+
routeService.getRoutes().forEach((routeMeta)=>{
|
|
1971
|
+
if (routeMeta.lang !== lang) return;
|
|
1972
|
+
const { routePath } = routeMeta;
|
|
1973
|
+
for(let i = 0; i < routeGroups.length; i++){
|
|
1974
|
+
const routeGroup = routeGroups[i];
|
|
1975
|
+
const navItem = navList[i];
|
|
1976
|
+
if (lang === navItem.lang && new RegExp(navItem.activeMatch ?? navItem.link).test(routePath)) return void routeGroup.push(routePath);
|
|
1977
|
+
}
|
|
1978
|
+
others.push(routePath);
|
|
1979
|
+
});
|
|
1980
|
+
for (const routeGroup of routeGroups)organizeBySidebar(sidebar, routeGroup);
|
|
1981
|
+
const llmsTxtContent = await generateLlmsTxt(routeGroups, others, navList, config.title, config.description, config.base, routeService);
|
|
1982
|
+
const llmsFullTxtContent = generateLlmsFullTxt(routeGroups, navList, others, base, mdContents);
|
|
1983
|
+
const prefix = defaultLang === lang ? '' : `${lang}/`;
|
|
1984
|
+
emitAsset(`${prefix}llms.txt`, llmsTxtContent);
|
|
1985
|
+
emitAsset(`${prefix}llms-full.txt`, llmsFullTxtContent);
|
|
1986
|
+
}));
|
|
1987
|
+
}
|
|
1988
|
+
function flatSidebar(sidebar) {
|
|
1989
|
+
if (!sidebar) return [];
|
|
1990
|
+
return sidebar.flatMap((i)=>{
|
|
1991
|
+
if ('string' == typeof i) return i;
|
|
1992
|
+
if ('link' in i && 'string' == typeof i.link) return [
|
|
1993
|
+
i.link,
|
|
1994
|
+
...flatSidebar(i?.items ?? [])
|
|
1995
|
+
];
|
|
1996
|
+
if ('items' in i && Array.isArray(i.items)) return flatSidebar(i.items);
|
|
1997
|
+
}).filter(Boolean);
|
|
1998
|
+
}
|
|
1999
|
+
function organizeBySidebar(sidebar, routes) {
|
|
2000
|
+
if (0 === routes.length) return;
|
|
2001
|
+
const route = routes[0];
|
|
2002
|
+
const currSidebar = (0, shared_.getSidebarDataGroup)(sidebar, route);
|
|
2003
|
+
if (0 === currSidebar.length) return;
|
|
2004
|
+
const orderList = flatSidebar(currSidebar);
|
|
2005
|
+
routes.sort((a, b)=>{
|
|
2006
|
+
let aIndex = orderList.findIndex((order)=>matchPath(order, a));
|
|
2007
|
+
if (-1 === aIndex) aIndex = Number.MAX_SAFE_INTEGER;
|
|
2008
|
+
let bIndex = orderList.findIndex((order)=>matchPath(order, b));
|
|
2009
|
+
if (-1 === bIndex) bIndex = Number.MAX_SAFE_INTEGER;
|
|
2010
|
+
return aIndex - bIndex;
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
async function renderPage_renderPage(route, ssrBundlePath) {
|
|
2014
|
+
let render;
|
|
2015
|
+
try {
|
|
2016
|
+
const { default: ssrExports } = await import((0, external_node_url_.pathToFileURL)(ssrBundlePath).toString());
|
|
2017
|
+
render = await ssrExports.render;
|
|
2018
|
+
} catch (e) {
|
|
2019
|
+
if (e instanceof Error) {
|
|
2020
|
+
logger.error(`Failed to load SSG bundle: ${picocolors.yellow(ssrBundlePath)}: ${e.message}`);
|
|
2021
|
+
logger.debug(e);
|
|
2022
|
+
hintSSGFailed();
|
|
2023
|
+
}
|
|
2024
|
+
throw e;
|
|
2025
|
+
}
|
|
2026
|
+
const head = createHead();
|
|
2027
|
+
const { routePath } = route;
|
|
2028
|
+
let appMd = '';
|
|
2029
|
+
if (render) try {
|
|
2030
|
+
({ appMd } = await render(routePath, head));
|
|
2031
|
+
} catch (e) {
|
|
2032
|
+
if (e instanceof Error) {
|
|
2033
|
+
logger.error(`Page "${picocolors.yellow(routePath)}" SSG-MD rendering failed.\n ${picocolors.gray(e.toString())}`);
|
|
2034
|
+
throw e;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
return appMd;
|
|
2038
|
+
}
|
|
2039
|
+
const routePage2MdFilename = (routePath)=>{
|
|
2040
|
+
let fileName = routePath;
|
|
2041
|
+
fileName = fileName.endsWith('/') ? `${routePath}index.md` : `${routePath}.md`;
|
|
2042
|
+
return fileName.replace(/^\/+/, '');
|
|
2043
|
+
};
|
|
2044
|
+
async function renderPages_renderPages(routeService, ssrBundlePath, emitAsset) {
|
|
2045
|
+
logger.info('Rendering md pages...');
|
|
2046
|
+
const startTime = Date.now();
|
|
2047
|
+
const result = new Map();
|
|
2048
|
+
const routes = routeService.getRoutes();
|
|
2049
|
+
await pMap(routes, async (route)=>{
|
|
2050
|
+
const html = await renderPage_renderPage(route, ssrBundlePath);
|
|
2051
|
+
const fileName = routePage2MdFilename(route.routePath);
|
|
2052
|
+
emitAsset(fileName, html);
|
|
2053
|
+
result.set(route.routePath, html);
|
|
2054
|
+
}, {
|
|
2055
|
+
concurrency: SSGConcurrency()
|
|
2056
|
+
});
|
|
2057
|
+
const totalTime = Date.now() - startTime;
|
|
2058
|
+
logger.success(`Markdown rendered in ${picocolors.yellow(totalTime)} ms.`);
|
|
2059
|
+
return result;
|
|
2060
|
+
}
|
|
2061
|
+
const rsbuildPluginSSGMD = ({ routeService, config })=>({
|
|
2062
|
+
name: 'rspress-inner-rsbuild-plugin-ssg',
|
|
2063
|
+
async setup (api) {
|
|
2064
|
+
api.onBeforeBuild(()=>{
|
|
2065
|
+
let hasError = false;
|
|
2066
|
+
api.processAssets({
|
|
2067
|
+
stage: 'optimize-transfer',
|
|
2068
|
+
environments: [
|
|
2069
|
+
'node_md'
|
|
2070
|
+
]
|
|
2071
|
+
}, async ({ assets, compilation, environment, compiler })=>{
|
|
2072
|
+
if (compilation.errors.length > 0) {
|
|
2073
|
+
hasError = true;
|
|
2074
|
+
return;
|
|
2075
|
+
}
|
|
2076
|
+
if (hasError) return;
|
|
2077
|
+
const emitAsset = (assetName, content)=>{
|
|
2078
|
+
compilation.emitAsset(assetName, new compiler.webpack.sources.RawSource(content));
|
|
2079
|
+
};
|
|
2080
|
+
const distPath = environment.distPath;
|
|
2081
|
+
const ssgFolderPath = (0, external_node_path_.join)(distPath, NODE_SSG_MD_BUNDLE_FOLDER);
|
|
2082
|
+
const mainCjsAbsolutePath = (0, external_node_path_.join)(ssgFolderPath, NODE_SSG_MD_BUNDLE_NAME);
|
|
2083
|
+
await mkdir(ssgFolderPath, {
|
|
2084
|
+
recursive: true
|
|
2085
|
+
});
|
|
2086
|
+
await Promise.all(Object.entries(assets).map(async ([assetName, assetSource])=>{
|
|
2087
|
+
if (assetName.startsWith(`${NODE_SSG_MD_BUNDLE_FOLDER}/`)) {
|
|
2088
|
+
const fileAbsolutePath = (0, external_node_path_.join)(distPath, assetName);
|
|
2089
|
+
await writeFile(fileAbsolutePath, assetSource.source().toString());
|
|
2090
|
+
compilation.deleteAsset(assetName);
|
|
2091
|
+
}
|
|
2092
|
+
}));
|
|
2093
|
+
const mdContents = await renderPages_renderPages(routeService, mainCjsAbsolutePath, emitAsset);
|
|
2094
|
+
await emitLlmsTxt(config, routeService, emitAsset, mdContents);
|
|
2095
|
+
if (!(0, shared_.isDebugMode)()) await rm(ssgFolderPath, {
|
|
2096
|
+
recursive: true
|
|
2097
|
+
});
|
|
2098
|
+
});
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
});
|
|
1841
2102
|
const Resolver = core_rspack.experiments.resolver.ResolverFactory;
|
|
1842
2103
|
async function detectPackageMajorVersion(name) {
|
|
1843
2104
|
const cwd = process.cwd();
|
|
@@ -1961,6 +2222,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1961
2222
|
detectCustomIcon(CUSTOM_THEME_DIR),
|
|
1962
2223
|
resolveReactAlias(reactVersion, false),
|
|
1963
2224
|
enableSSG ? resolveReactAlias(reactVersion, true) : Promise.resolve({}),
|
|
2225
|
+
resolveReactAlias(reactVersion, true),
|
|
1964
2226
|
resolveReactRouterDomAlias()
|
|
1965
2227
|
]);
|
|
1966
2228
|
const context = {
|
|
@@ -1993,13 +2255,17 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
1993
2255
|
...siteDataVMPlugin(context)
|
|
1994
2256
|
}
|
|
1995
2257
|
}),
|
|
1996
|
-
enableSSG ? rsbuildPluginSSG({
|
|
2258
|
+
enableSSG && config.ssg ? rsbuildPluginSSG({
|
|
1997
2259
|
routeService,
|
|
1998
2260
|
config
|
|
1999
2261
|
}) : rsbuildPluginCSR({
|
|
2000
2262
|
routeService,
|
|
2001
2263
|
config
|
|
2002
|
-
})
|
|
2264
|
+
}),
|
|
2265
|
+
enableSSG && config.llms ? rsbuildPluginSSGMD({
|
|
2266
|
+
routeService,
|
|
2267
|
+
config
|
|
2268
|
+
}) : null
|
|
2003
2269
|
],
|
|
2004
2270
|
server: {
|
|
2005
2271
|
port: !isProduction() && process.env.PORT ? Number(process.env.PORT) : void 0,
|
|
@@ -2092,8 +2358,9 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2092
2358
|
}
|
|
2093
2359
|
},
|
|
2094
2360
|
tools: {
|
|
2095
|
-
bundlerChain (chain, { CHAIN_ID,
|
|
2096
|
-
const
|
|
2361
|
+
bundlerChain (chain, { CHAIN_ID, environment }) {
|
|
2362
|
+
const isSsg = 'node' === environment.name;
|
|
2363
|
+
const isSsgMd = 'node_md' === environment.name;
|
|
2097
2364
|
const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
2098
2365
|
const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
|
|
2099
2366
|
chain.module.rule('MDX').type("javascript/auto").test(shared_.MDX_OR_MD_REGEXP).resolve.merge({
|
|
@@ -2103,7 +2370,8 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2103
2370
|
config,
|
|
2104
2371
|
docDirectory: userDocRoot,
|
|
2105
2372
|
routeService,
|
|
2106
|
-
pluginDriver
|
|
2373
|
+
pluginDriver,
|
|
2374
|
+
isSsgMd
|
|
2107
2375
|
}).end();
|
|
2108
2376
|
chain.experiments({
|
|
2109
2377
|
...chain.get('experiments'),
|
|
@@ -2125,10 +2393,14 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2125
2393
|
chain.module.rule('css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
|
|
2126
2394
|
sideEffects: true
|
|
2127
2395
|
});
|
|
2128
|
-
if (
|
|
2396
|
+
if (isSsg) {
|
|
2129
2397
|
chain.output.filename(`${NODE_SSG_BUNDLE_FOLDER}/${NODE_SSG_BUNDLE_NAME}`);
|
|
2130
2398
|
chain.output.chunkFilename(`${NODE_SSG_BUNDLE_FOLDER}/[name].cjs`);
|
|
2131
|
-
chain.
|
|
2399
|
+
chain.output.set('asyncChunks', false);
|
|
2400
|
+
} else if (isSsgMd) {
|
|
2401
|
+
chain.output.filename(`${NODE_SSG_MD_BUNDLE_FOLDER}/${NODE_SSG_MD_BUNDLE_NAME}`);
|
|
2402
|
+
chain.output.chunkFilename(`${NODE_SSG_MD_BUNDLE_FOLDER}/[name].cjs`);
|
|
2403
|
+
chain.output.set('asyncChunks', false);
|
|
2132
2404
|
}
|
|
2133
2405
|
}
|
|
2134
2406
|
},
|
|
@@ -2149,7 +2421,8 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2149
2421
|
'virtual-global-styles'
|
|
2150
2422
|
],
|
|
2151
2423
|
define: {
|
|
2152
|
-
'process.env.__SSR__': JSON.stringify(false)
|
|
2424
|
+
'process.env.__SSR__': JSON.stringify(false),
|
|
2425
|
+
'process.env.__SSR_MD__': JSON.stringify(false)
|
|
2153
2426
|
}
|
|
2154
2427
|
},
|
|
2155
2428
|
output: {
|
|
@@ -2159,7 +2432,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2159
2432
|
}
|
|
2160
2433
|
}
|
|
2161
2434
|
},
|
|
2162
|
-
...enableSSG ? {
|
|
2435
|
+
...enableSSG && config.ssg ? {
|
|
2163
2436
|
node: {
|
|
2164
2437
|
resolve: {
|
|
2165
2438
|
alias: {
|
|
@@ -2172,7 +2445,45 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
|
|
|
2172
2445
|
index: SSR_SERVER_ENTRY
|
|
2173
2446
|
},
|
|
2174
2447
|
define: {
|
|
2175
|
-
'process.env.__SSR__': JSON.stringify(true)
|
|
2448
|
+
'process.env.__SSR__': JSON.stringify(true),
|
|
2449
|
+
'process.env.__SSR_MD__': JSON.stringify(false)
|
|
2450
|
+
}
|
|
2451
|
+
},
|
|
2452
|
+
performance: {
|
|
2453
|
+
printFileSize: {
|
|
2454
|
+
compressed: true
|
|
2455
|
+
}
|
|
2456
|
+
},
|
|
2457
|
+
output: {
|
|
2458
|
+
emitAssets: false,
|
|
2459
|
+
target: 'node',
|
|
2460
|
+
minify: false
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
} : {},
|
|
2464
|
+
...enableSSG && config.llms ? {
|
|
2465
|
+
node_md: {
|
|
2466
|
+
resolve: {
|
|
2467
|
+
alias: {
|
|
2468
|
+
...reactSSRAlias,
|
|
2469
|
+
...reactRouterDomAlias
|
|
2470
|
+
}
|
|
2471
|
+
},
|
|
2472
|
+
tools: {
|
|
2473
|
+
rspack: {
|
|
2474
|
+
optimization: {
|
|
2475
|
+
moduleIds: 'named',
|
|
2476
|
+
chunkIds: 'named'
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
},
|
|
2480
|
+
source: {
|
|
2481
|
+
entry: {
|
|
2482
|
+
index: SSG_MD_SERVER_ENTRY
|
|
2483
|
+
},
|
|
2484
|
+
define: {
|
|
2485
|
+
'process.env.__SSR__': JSON.stringify(true),
|
|
2486
|
+
'process.env.__SSR_MD__': JSON.stringify(true)
|
|
2176
2487
|
}
|
|
2177
2488
|
},
|
|
2178
2489
|
performance: {
|
|
@@ -2258,7 +2569,13 @@ class PluginDriver {
|
|
|
2258
2569
|
const index = this.#plugins.findIndex((item)=>item.name === pluginName);
|
|
2259
2570
|
if (-1 !== index) this.#plugins.splice(index, 1);
|
|
2260
2571
|
}
|
|
2572
|
+
async normalizeConfig() {
|
|
2573
|
+
this.#config.ssg ??= true;
|
|
2574
|
+
this.#config.llms ??= false;
|
|
2575
|
+
this.#config.base = (0, shared_.addTrailingSlash)((0, shared_.addLeadingSlash)(this.#config.base ?? '/'));
|
|
2576
|
+
}
|
|
2261
2577
|
async modifyConfig() {
|
|
2578
|
+
this.normalizeConfig();
|
|
2262
2579
|
let config = this.#config;
|
|
2263
2580
|
for(let i = 0; i < this.#plugins.length; i++){
|
|
2264
2581
|
const plugin = this.#plugins[i];
|
|
@@ -2402,7 +2719,7 @@ async function build(options) {
|
|
|
2402
2719
|
const { docDirectory, config, configFilePath } = options;
|
|
2403
2720
|
const pluginDriver = await PluginDriver.create(config, configFilePath, true);
|
|
2404
2721
|
const modifiedConfig = await pluginDriver.modifyConfig();
|
|
2405
|
-
const
|
|
2722
|
+
const enableSSG = Boolean((modifiedConfig.ssg || modifiedConfig.llms) ?? true);
|
|
2406
2723
|
const additionalPages = await pluginDriver.addPages();
|
|
2407
2724
|
const routeService = await RouteService.create({
|
|
2408
2725
|
config: modifiedConfig,
|
|
@@ -2414,13 +2731,13 @@ async function build(options) {
|
|
|
2414
2731
|
await modifyConfigWithAutoNavSide(modifiedConfig);
|
|
2415
2732
|
try {
|
|
2416
2733
|
await pluginDriver.beforeBuild();
|
|
2417
|
-
const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService,
|
|
2734
|
+
const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, enableSSG);
|
|
2418
2735
|
await rsbuild.build();
|
|
2419
2736
|
} finally{
|
|
2420
2737
|
await checkLanguageParity(config);
|
|
2421
2738
|
}
|
|
2422
2739
|
await pluginDriver.afterBuild();
|
|
2423
|
-
if (!
|
|
2740
|
+
if (!enableSSG) hintSSGFalse();
|
|
2424
2741
|
}
|
|
2425
2742
|
async function dev(options) {
|
|
2426
2743
|
const { docDirectory, config, extraBuilderConfig, configFilePath } = options;
|
|
@@ -2563,15 +2880,20 @@ function normalizeLink(nodeUrl, routeService, filePath, cleanUrls, autoPrefix, d
|
|
|
2563
2880
|
const anotherFileAbsolutePath = external_node_path_["default"].join(external_node_path_["default"].dirname(filePath), url);
|
|
2564
2881
|
url = routeService.absolutePathToRoutePath(anotherFileAbsolutePath);
|
|
2565
2882
|
}
|
|
2566
|
-
if ('boolean' == typeof cleanUrls)
|
|
2567
|
-
|
|
2883
|
+
if ('boolean' == typeof cleanUrls) {
|
|
2884
|
+
url = (0, shared_.normalizeHref)(url, cleanUrls);
|
|
2885
|
+
if (!routeService.isExistRoute(url)) {
|
|
2886
|
+
deadLinks.set(nodeUrl, url);
|
|
2887
|
+
return nodeUrl;
|
|
2888
|
+
}
|
|
2889
|
+
} else {
|
|
2568
2890
|
url = (0, shared_.normalizeHref)(url, false);
|
|
2891
|
+
if (!routeService.isExistRoute(url)) {
|
|
2892
|
+
deadLinks.set(nodeUrl, url);
|
|
2893
|
+
return nodeUrl;
|
|
2894
|
+
}
|
|
2569
2895
|
url = url.replace(/\.html$/, cleanUrls);
|
|
2570
2896
|
}
|
|
2571
|
-
if (!routeService.isExistRoute(url)) {
|
|
2572
|
-
deadLinks.set(nodeUrl, url);
|
|
2573
|
-
return nodeUrl;
|
|
2574
|
-
}
|
|
2575
2897
|
if (hash) url += `#${hash}`;
|
|
2576
2898
|
if (__base) url = (0, shared_.withBase)(url, __base);
|
|
2577
2899
|
return url;
|