@rspress/core 1.0.1 → 1.1.0
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/README.md +2 -25
- package/dist/index.js +64 -16
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -0
- package/dist/loader.js +24 -105
- package/dist/loader.js.map +1 -1
- package/dist/theme/bundle.css +291 -293
- package/dist/theme/bundle.d.ts +1 -1
- package/dist/theme/bundle.js +567 -511
- package/dist/theme/bundle.js.map +1 -1
- package/package.json +14 -14
- package/src/theme-default/components/HomeHero/index.tsx +5 -4
- package/src/theme-default/components/Nav/NavBarTitle.tsx +2 -1
- package/src/theme-default/components/Nav/NavMenuGroup.tsx +1 -14
- package/src/theme-default/components/Nav/NavTranslations.tsx +16 -0
- package/src/theme-default/components/Nav/NavVersions.tsx +16 -0
- package/src/theme-default/components/Nav/index.tsx +12 -50
- package/src/theme-default/components/Nav/menuDataHooks.tsx +75 -0
- package/src/theme-default/components/{NavScreenMenuGroup → NavScreen}/NavScreenMenuGroup.tsx +1 -1
- package/src/theme-default/components/NavScreen/index.module.scss +42 -0
- package/src/theme-default/components/NavScreen/index.tsx +26 -54
- package/src/theme-default/components/Overview/index.module.scss +4 -5
- package/src/theme-default/components/Overview/index.tsx +7 -2
- package/src/theme-default/components/Search/index.module.scss +2 -0
- package/src/theme-default/components/Search/index.tsx +11 -3
- package/src/theme-default/components/Sidebar/index.tsx +1 -1
- package/src/theme-default/components/SocialLinks/HiddenLinks.tsx +1 -1
- package/src/theme-default/components/SocialLinks/ShownLinks.tsx +1 -1
- package/src/theme-default/layout/DocLayout/docComponents/code.tsx +4 -27
- package/src/theme-default/layout/DocLayout/index.module.scss +1 -0
- package/src/theme-default/layout/DocLayout/index.tsx +15 -5
- package/src/theme-default/layout/Layout/index.tsx +25 -1
- package/src/theme-default/logic/useHiddenNav.ts +4 -1
- package/src/theme-default/components/NavScreenMenuGroup/index.module.scss +0 -41
package/README.md
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
3
|
-
</p>
|
|
1
|
+
# @rspress/core
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<p align="center">
|
|
8
|
-
The Documentation Framework of Modern.js.
|
|
9
|
-
</p>
|
|
10
|
-
|
|
11
|
-
## Getting Started
|
|
12
|
-
|
|
13
|
-
Please follow [Quick Start](https://modernjs.dev/doc-tools/guide/getting-started.html) to get started with Modern.js Doc.
|
|
14
|
-
|
|
15
|
-
## Documentation
|
|
16
|
-
|
|
17
|
-
- [English Documentation](https://modernjs.dev/doc-tools/)
|
|
18
|
-
- [中文文档](https://modernjs.dev/doc-tools/zh/)
|
|
19
|
-
|
|
20
|
-
## Contributing
|
|
21
|
-
|
|
22
|
-
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
|
23
|
-
|
|
24
|
-
## License
|
|
25
|
-
|
|
26
|
-
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
|
3
|
+
The core pacakge for [Rspress](https://rspress.dev).
|
package/dist/index.js
CHANGED
|
@@ -769,6 +769,49 @@ async function searchHookVMPlugin(context) {
|
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
771
|
|
|
772
|
+
// src/node/runtimeModule/prismLanguages.ts
|
|
773
|
+
import { uniqBy } from "lodash-es";
|
|
774
|
+
var DEFAULT_LANGUAGES = [
|
|
775
|
+
["js", "javascript"],
|
|
776
|
+
["ts", "typescript"],
|
|
777
|
+
["jsx", "tsx"],
|
|
778
|
+
"tsx",
|
|
779
|
+
"json",
|
|
780
|
+
"css",
|
|
781
|
+
"scss",
|
|
782
|
+
"less",
|
|
783
|
+
["xml", "xml-doc"],
|
|
784
|
+
"diff",
|
|
785
|
+
"yaml",
|
|
786
|
+
["md", "markdown"],
|
|
787
|
+
["mdx", "tsx"]
|
|
788
|
+
];
|
|
789
|
+
async function prismLanguageVMPlugin(context) {
|
|
790
|
+
const { config } = context;
|
|
791
|
+
const { highlightLanguages = [] } = config.markdown || {};
|
|
792
|
+
const languageMeta = uniqBy(
|
|
793
|
+
[...DEFAULT_LANGUAGES, ...highlightLanguages].map((language) => {
|
|
794
|
+
const [alias, name] = Array.isArray(language) ? language : [language, language];
|
|
795
|
+
return { alias, name };
|
|
796
|
+
}),
|
|
797
|
+
"alias"
|
|
798
|
+
);
|
|
799
|
+
const importStatement = languageMeta.map((language) => {
|
|
800
|
+
const { alias, name } = language;
|
|
801
|
+
return `import ${alias} from 'react-syntax-highlighter/dist/esm/languages/prism/${name}'`;
|
|
802
|
+
});
|
|
803
|
+
const moduleContent = `
|
|
804
|
+
${importStatement.join("\n")}
|
|
805
|
+
|
|
806
|
+
export default {
|
|
807
|
+
${languageMeta.map(({ alias }) => `"${alias}": ${alias}`)}
|
|
808
|
+
};
|
|
809
|
+
`;
|
|
810
|
+
return {
|
|
811
|
+
["virtual-prism-languages" /* PrismLanguages */]: moduleContent
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
|
|
772
815
|
// src/node/runtimeModule/index.ts
|
|
773
816
|
var runtimeModuleFactory = [
|
|
774
817
|
/**
|
|
@@ -794,7 +837,11 @@ var runtimeModuleFactory = [
|
|
|
794
837
|
/**
|
|
795
838
|
* Generate search hook module
|
|
796
839
|
*/
|
|
797
|
-
searchHookVMPlugin
|
|
840
|
+
searchHookVMPlugin,
|
|
841
|
+
/**
|
|
842
|
+
* Generate prism languages module
|
|
843
|
+
*/
|
|
844
|
+
prismLanguageVMPlugin
|
|
798
845
|
];
|
|
799
846
|
function builderDocVMPlugin(factoryContext) {
|
|
800
847
|
return {
|
|
@@ -1154,13 +1201,7 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
|
|
|
1154
1201
|
return icon;
|
|
1155
1202
|
};
|
|
1156
1203
|
const browserslist = {
|
|
1157
|
-
web: isProduction() ? [
|
|
1158
|
-
"chrome >= 61",
|
|
1159
|
-
"edge >= 16",
|
|
1160
|
-
"firefox >= 60",
|
|
1161
|
-
"safari >= 11",
|
|
1162
|
-
"ios_saf >= 11"
|
|
1163
|
-
] : [
|
|
1204
|
+
web: isProduction() ? ["chrome >= 87", "edge >= 88", "firefox >= 78", "safari >= 14"] : [
|
|
1164
1205
|
"last 1 chrome version",
|
|
1165
1206
|
"last 1 firefox version",
|
|
1166
1207
|
"last 1 safari version"
|
|
@@ -1198,6 +1239,11 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
|
|
|
1198
1239
|
"@/theme-default": DEFAULT_THEME_DIR,
|
|
1199
1240
|
"@rspress/core": PACKAGE_ROOT,
|
|
1200
1241
|
"react-lazy-with-preload": __require.resolve("react-lazy-with-preload"),
|
|
1242
|
+
"react-syntax-highlighter": path8.join(
|
|
1243
|
+
PACKAGE_ROOT,
|
|
1244
|
+
"node_modules",
|
|
1245
|
+
"react-syntax-highlighter"
|
|
1246
|
+
),
|
|
1201
1247
|
...await resolveReactAlias(reactVersion)
|
|
1202
1248
|
},
|
|
1203
1249
|
include: [PACKAGE_ROOT],
|
|
@@ -1235,13 +1281,6 @@ async function createInternalBuildConfig(userDocRoot, config, isSSR, routeServic
|
|
|
1235
1281
|
);
|
|
1236
1282
|
}
|
|
1237
1283
|
},
|
|
1238
|
-
rspack: {
|
|
1239
|
-
// This config can be removed after upgrading Rspack v0.4
|
|
1240
|
-
// https://github.com/web-infra-dev/rspack/issues/3096
|
|
1241
|
-
optimization: {
|
|
1242
|
-
chunkIds: isProduction() ? "deterministic" : "named"
|
|
1243
|
-
}
|
|
1244
|
-
},
|
|
1245
1284
|
bundlerChain(chain) {
|
|
1246
1285
|
chain.module.rule("MDX").type("jsx").test(/\.mdx?$/).oneOf("MDXCompile").use("mdx-loader").loader(__require.resolve("../loader.cjs")).options({
|
|
1247
1286
|
config,
|
|
@@ -1370,11 +1409,20 @@ var PluginDriver = class {
|
|
|
1370
1409
|
clearPlugins() {
|
|
1371
1410
|
__privateSet(this, _plugins, []);
|
|
1372
1411
|
}
|
|
1412
|
+
removePlugin(pluginName) {
|
|
1413
|
+
const index = __privateGet(this, _plugins).findIndex((item) => item.name === pluginName);
|
|
1414
|
+
if (index !== -1) {
|
|
1415
|
+
__privateGet(this, _plugins).splice(index, 1);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1373
1418
|
async modifyConfig() {
|
|
1374
1419
|
let config = __privateGet(this, _config);
|
|
1375
1420
|
for (const plugin of __privateGet(this, _plugins)) {
|
|
1376
1421
|
if (typeof plugin.config === "function") {
|
|
1377
|
-
config = await plugin.config(config || {}
|
|
1422
|
+
config = await plugin.config(config || {}, {
|
|
1423
|
+
addPlugin: this.addPlugin.bind(this),
|
|
1424
|
+
removePlugin: this.removePlugin.bind(this)
|
|
1425
|
+
});
|
|
1378
1426
|
}
|
|
1379
1427
|
}
|
|
1380
1428
|
__privateSet(this, _config, config);
|