rspress-plugin-gh-pages 0.1.0 → 0.1.1
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 +29 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +15 -6
- package/doc_build/index.html +1 -1
- package/doc_build/static/js/{index.2e2891ec.js → index.4ffb173e.js} +2 -2
- package/doc_build/static/js/{index.2e2891ec.js.LICENSE.txt → index.4ffb173e.js.LICENSE.txt} +156 -156
- package/doc_build/static/search_index.fb3fdf3b.json +1 -0
- package/package.json +1 -1
- package/src/index.ts +29 -8
- package/doc_build/static/search_index.a36e1c1a.json +0 -1
package/src/index.ts
CHANGED
|
@@ -4,42 +4,63 @@ import chalk from 'chalk';
|
|
|
4
4
|
import ghpages from 'gh-pages';
|
|
5
5
|
import { logger } from '@rspress/shared/logger';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import type { MarkRequired } from 'rspress-plugin-devkit';
|
|
8
8
|
import type { RspressPlugin } from '@rspress/shared';
|
|
9
9
|
|
|
10
10
|
export const componentsPath = path.join(__dirname, './components');
|
|
11
11
|
|
|
12
12
|
const DefaultDocBuildOutput = 'doc_build';
|
|
13
13
|
|
|
14
|
-
interface RspressPluginGHPagesOptions
|
|
14
|
+
interface RspressPluginGHPagesOptions
|
|
15
|
+
extends MarkRequired<ghpages.PublishOptions, 'repo'> {
|
|
15
16
|
directory?: string;
|
|
16
17
|
silent?: boolean;
|
|
18
|
+
siteBase?: string;
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
const logPrefix = chalk.green('[gh-pages]');
|
|
22
|
+
|
|
19
23
|
export default function rspressPluginGHPages(
|
|
20
|
-
options: RspressPluginGHPagesOptions
|
|
24
|
+
options: RspressPluginGHPagesOptions,
|
|
21
25
|
): RspressPlugin {
|
|
22
26
|
const {
|
|
23
|
-
directory,
|
|
24
27
|
repo,
|
|
28
|
+
directory,
|
|
25
29
|
branch = 'gh-pages',
|
|
26
30
|
silent = false,
|
|
31
|
+
siteBase = '',
|
|
27
32
|
...publishOptions
|
|
28
33
|
} = options;
|
|
29
34
|
|
|
30
35
|
return {
|
|
31
36
|
name: 'rspress-plugin-gh-pages',
|
|
32
37
|
config(config) {
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
// Use || here to as ?? will consider '' as a valid value
|
|
39
|
+
const base = siteBase || /\/([^\/]+)\.git$/.exec(repo)?.[1] || '';
|
|
40
|
+
|
|
41
|
+
if (!base) {
|
|
42
|
+
logger.warn(
|
|
43
|
+
`${logPrefix} Failed to parse base from repo, site base path will not be updated.`,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
config.base = `/${base}/`;
|
|
50
|
+
|
|
51
|
+
return config;
|
|
35
52
|
},
|
|
36
53
|
async afterBuild(config, isBuild) {
|
|
54
|
+
if (!repo) {
|
|
55
|
+
logger.error(
|
|
56
|
+
`Option ${chalk.cyan('repo')} is required for rspress-plugin-gh-pages.`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
37
60
|
if (!isBuild) return;
|
|
38
61
|
|
|
39
62
|
const publishDir = directory ?? config.outDir ?? DefaultDocBuildOutput;
|
|
40
63
|
|
|
41
|
-
const logPrefix = chalk.green('[rspress-plugin-gh-pages]');
|
|
42
|
-
|
|
43
64
|
if (!silent) {
|
|
44
65
|
logger.info(
|
|
45
66
|
`${logPrefix} Publish directory: ${chalk.cyan(publishDir)}`,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"id":0,"title":"RSPress x GH Pages","content":"#","routePath":"/rspress-plugins/","lang":"","toc":[],"domain":"","frontmatter":{},"version":""}]
|