@rspress-theme-anatole/theme-default 0.6.1-alpha.0 → 0.6.2

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.
Files changed (2) hide show
  1. package/dist/bundle.js +64 -5
  2. package/package.json +3 -3
package/dist/bundle.js CHANGED
@@ -41,7 +41,6 @@ import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_jump_20d3ca88__ from "@theme
41
41
  import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_title_56a7311e__ from "@theme-assets/title";
42
42
  import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_github_cac38251__ from "@theme-assets/github";
43
43
  import * as __WEBPACK_EXTERNAL_MODULE__theme_assets_gitlab_a0e4f082__ from "@theme-assets/gitlab";
44
- import html2pdf from "html2pdf.js";
45
44
 
46
45
  function isMobileDevice() {
47
46
  return window.innerWidth < 1280;
@@ -391,7 +390,7 @@ function DocFooter() {
391
390
  (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
392
391
  className: "flex flex-col",
393
392
  children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.EditLink, {})
394
- }),
393
+ }),
395
394
  (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
396
395
  className: "flex flex-col sm:flex-row sm:justify-around gap-4 pt-6",
397
396
  children: [
@@ -803,6 +802,7 @@ function Sidebar(props) {
803
802
  ]);
804
803
  return (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("aside", {
805
804
  className: `${Sidebar_index_module.sidebar} rspress-sidebar ${isSidebarOpen ? Sidebar_index_module.open : ''}`,
805
+ style: { display: 'flex', flexDirection: 'column', height: '100vh' }, // 1. 让 aside 占满视口高度
806
806
  children: [
807
807
  uiSwitch?.showNavbar ? (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
808
808
  className: Sidebar_index_module.navTitleMask,
@@ -810,6 +810,7 @@ function Sidebar(props) {
810
810
  }) : null,
811
811
  (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
812
812
  className: `rspress-scrollbar ${Sidebar_index_module.sidebarContent}`,
813
+ style: { flex: 1, minHeight: 0, overflowY: 'auto' }, // 2. 让内容区可滚动并撑满剩余空间
813
814
  children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("nav", {
814
815
  className: "pb-2",
815
816
  children: [
@@ -821,6 +822,65 @@ function Sidebar(props) {
821
822
  afterSidebar
822
823
  ]
823
824
  })
825
+ }),
826
+ // 3. Download PDF 按钮放到 aside 最底部
827
+ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
828
+ style: {
829
+ margin: '0 0 24px 0',
830
+ padding: '0 16px',
831
+ textAlign: 'left'
832
+ },
833
+ children: (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("a", {
834
+ href: (() => {
835
+ if (typeof window === 'undefined') return '/index.pdf'; // SSR fallback
836
+ // 获取当前url路径
837
+ let path = window.location.pathname;
838
+ // 去掉开头和结尾的斜杠
839
+ path = path.replace(/^\/|\/$/g, '');
840
+ // 拆分路径
841
+ const parts = path.split('/');
842
+ // 如果最后一段包含.,说明是文件,去掉
843
+ if (parts.length && parts[parts.length - 1].includes('.')) {
844
+ parts.pop();
845
+ }
846
+ // 取前两级
847
+ const first = parts[0] || 'index';
848
+ const second = parts[1] || '';
849
+ // 拼接文件名
850
+ let fileName = '';
851
+ if (second) {
852
+ fileName = `/${first}_${second}.pdf`;
853
+ } else if (first) {
854
+ fileName = `/${first}.pdf`;
855
+ } else {
856
+ fileName = '/index.pdf';
857
+ }
858
+ return fileName;
859
+ })(),
860
+ target: "_blank", // 新开标签页
861
+ style: {
862
+ display: 'inline-block',
863
+ width: '100%',
864
+ fontWeight: 500,
865
+ fontSize: '15px',
866
+ color: '#EF483D',
867
+ border: '1px solid #EF483D',
868
+ borderRadius: '8px',
869
+ padding: '10px 0',
870
+ textAlign: 'center',
871
+ marginTop: '8px',
872
+ background: 'transparent',
873
+ transition: 'background 0.2s, color 0.2s'
874
+ },
875
+ className: "sidebar-download-pdf-btn",
876
+ children: [
877
+ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("i", {
878
+ className: "fa-regular fa-file-pdf",
879
+ style: { marginRight: '8px' }
880
+ }),
881
+ "Download PDF"
882
+ ]
883
+ })
824
884
  })
825
885
  ]
826
886
  });
@@ -5518,11 +5578,10 @@ async function exportContentToPDF() {
5518
5578
  });
5519
5579
  document.body.appendChild(tip);
5520
5580
 
5581
+ const html2pdf = (await import('html2pdf.js')).default;
5582
+
5521
5583
  fixMermaidSVGs();
5522
5584
 
5523
- // if (!window.html2pdf) {
5524
- // await loadScript('https://cdn.jsdelivr.net/npm/html2pdf.js@0.10.1/dist/html2pdf.bundle.min.js');
5525
- // }
5526
5585
  const element = document.querySelector('.rspress-doc');
5527
5586
  if (!element) {
5528
5587
  alert('No content to export.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rspress-theme-anatole/theme-default",
3
3
  "author": "Anatole Tong",
4
- "version": "0.6.1-alpha.0",
4
+ "version": "0.6.2",
5
5
  "license": "MIT",
6
6
  "sideEffects": [
7
7
  "*.css",
@@ -21,8 +21,8 @@
21
21
  "types": "./dist/bundle.d.ts",
22
22
  "dependencies": {
23
23
  "@mdx-js/react": "2.3.0",
24
- "@rspress-theme-anatole/rspress-plugin-mermaid": "0.6.1-alpha.0",
25
- "@rspress-theme-anatole/shared": "0.6.1-alpha.0",
24
+ "@rspress-theme-anatole/rspress-plugin-mermaid": "0.6.2",
25
+ "@rspress-theme-anatole/shared": "0.6.2",
26
26
  "@rspress/runtime": "1.43.8",
27
27
  "body-scroll-lock": "4.0.0-beta.0",
28
28
  "copy-to-clipboard": "^3.3.3",