rspress-plugin-gh-pages 0.1.2 → 0.1.3

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/index.js CHANGED
@@ -3,6 +3,11 @@ import ghpages from 'gh-pages';
3
3
  import { logger } from '@rspress/shared/logger';
4
4
  const DefaultDocBuildOutput = 'doc_build';
5
5
  const logPrefix = chalk.green('[gh-pages]');
6
+ function normalizeBase(base) {
7
+ return base === '/' || base === ''
8
+ ? '/'
9
+ : `/${base.replace(/^\/+|\/+$/g, '')}/`;
10
+ }
6
11
  export default function rspressPluginGHPages(options) {
7
12
  const { repo, directory, branch = 'gh-pages', silent = false, siteBase = '', ...publishOptions } = options;
8
13
  return {
@@ -18,7 +23,7 @@ export default function rspressPluginGHPages(options) {
18
23
  logger.warn(`${logPrefix} Failed to parse base from repo, site base path will not be updated.`);
19
24
  return config;
20
25
  }
21
- config.base = `/${base}/`;
26
+ config.base = normalizeBase(base);
22
27
  return config;
23
28
  },
24
29
  async afterBuild(config, isBuild) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rspress-plugin-gh-pages",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Rspress plugin that add support for automatic deployment to GitHub Pages",
5
5
  "keywords": [
6
6
  "rspress",
package/src/index.ts CHANGED
@@ -16,6 +16,12 @@ interface RspressPluginGHPagesOptions
16
16
 
17
17
  const logPrefix = chalk.green('[gh-pages]');
18
18
 
19
+ function normalizeBase(base: string): string {
20
+ return base === '/' || base === ''
21
+ ? '/'
22
+ : `/${base.replace(/^\/+|\/+$/g, '')}/`;
23
+ }
24
+
19
25
  export default function rspressPluginGHPages(
20
26
  options: RspressPluginGHPagesOptions,
21
27
  ): RspressPlugin {
@@ -46,7 +52,7 @@ export default function rspressPluginGHPages(
46
52
  return config;
47
53
  }
48
54
 
49
- config.base = `/${base}/`;
55
+ config.base = normalizeBase(base);
50
56
 
51
57
  return config;
52
58
  },