rspress-plugin-gh-pages 0.1.1 → 0.1.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.
package/README.md CHANGED
@@ -27,3 +27,20 @@ export default defineConfig({
27
27
  ],
28
28
  });
29
29
  ```
30
+
31
+ ## Configure
32
+
33
+ ## repo
34
+
35
+ - Type: `string`
36
+ - `Required`
37
+
38
+ The repository to deploy to, you can also specify another repository to deploy to.
39
+
40
+ ## siteBase
41
+
42
+ - Type: `string`
43
+
44
+ Deploying to repositories other than the `<user>.github.io` repository requires specifying the `siteBase` option, as an example, deploying to repository `<user>/awesome-plugins` will require setting `siteBase` to `/awesome-plugins`, as the page will be hosted at `https://<user>.github.io/awesome-plugins`.
45
+
46
+ By default, `rspress-plugin-gh-pages` will try to parse the `repo` option to get a `siteBase` value(if repo is a `github.io` repository, the `siteBase` will be `/`, otherwise, the `siteBase` will be `/<repo-name>`), you can also specify the `siteBase` option to override the default value.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import ghpages from 'gh-pages';
2
2
  import type { MarkRequired } from 'rspress-plugin-devkit';
3
3
  import type { RspressPlugin } from '@rspress/shared';
4
- export declare const componentsPath: string;
5
4
  interface RspressPluginGHPagesOptions extends MarkRequired<ghpages.PublishOptions, 'repo'> {
6
5
  directory?: string;
7
6
  silent?: boolean;
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
- import path from 'node:path';
2
1
  import chalk from 'chalk';
3
2
  import ghpages from 'gh-pages';
4
3
  import { logger } from '@rspress/shared/logger';
5
- export const componentsPath = path.join(__dirname, './components');
6
4
  const DefaultDocBuildOutput = 'doc_build';
7
5
  const logPrefix = chalk.green('[gh-pages]');
8
6
  export default function rspressPluginGHPages(options) {
@@ -11,8 +9,11 @@ export default function rspressPluginGHPages(options) {
11
9
  name: 'rspress-plugin-gh-pages',
12
10
  config(config) {
13
11
  var _a;
12
+ let baseFromRepo = repo.includes('github.io')
13
+ ? '/'
14
+ : (_a = /\/([^\/]+)\.git$/.exec(repo)) === null || _a === void 0 ? void 0 : _a[1];
14
15
  // Use || here to as ?? will consider '' as a valid value
15
- const base = siteBase || ((_a = /\/([^\/]+)\.git$/.exec(repo)) === null || _a === void 0 ? void 0 : _a[1]) || '';
16
+ const base = siteBase || baseFromRepo || '';
16
17
  if (!base) {
17
18
  logger.warn(`${logPrefix} Failed to parse base from repo, site base path will not be updated.`);
18
19
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rspress-plugin-gh-pages",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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
@@ -1,5 +1,3 @@
1
- import path from 'node:path';
2
-
3
1
  import chalk from 'chalk';
4
2
  import ghpages from 'gh-pages';
5
3
  import { logger } from '@rspress/shared/logger';
@@ -7,8 +5,6 @@ import { logger } from '@rspress/shared/logger';
7
5
  import type { MarkRequired } from 'rspress-plugin-devkit';
8
6
  import type { RspressPlugin } from '@rspress/shared';
9
7
 
10
- export const componentsPath = path.join(__dirname, './components');
11
-
12
8
  const DefaultDocBuildOutput = 'doc_build';
13
9
 
14
10
  interface RspressPluginGHPagesOptions
@@ -35,8 +31,12 @@ export default function rspressPluginGHPages(
35
31
  return {
36
32
  name: 'rspress-plugin-gh-pages',
37
33
  config(config) {
34
+ let baseFromRepo = repo.includes('github.io')
35
+ ? '/'
36
+ : /\/([^\/]+)\.git$/.exec(repo)?.[1];
37
+
38
38
  // Use || here to as ?? will consider '' as a valid value
39
- const base = siteBase || /\/([^\/]+)\.git$/.exec(repo)?.[1] || '';
39
+ const base = siteBase || baseFromRepo || '';
40
40
 
41
41
  if (!base) {
42
42
  logger.warn(