rspress-plugin-gh-pages 0.1.0 → 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 +46 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +18 -8
- 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 +33 -12
- package/doc_build/static/search_index.a36e1c1a.json +0 -1
package/README.md
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
|
-
# rspress-plugin-gh-pages
|
|
1
|
+
# rspress-plugin-gh-pages 
|
|
2
|
+
|
|
3
|
+
Rspress plugin to add support for automatic deployment to GitHub Pages.
|
|
4
|
+
|
|
5
|
+
- **No need to push the code and wait for the pages to be updated**: Every time you run `rspress build`, the plugin will automatically push the generated files to the specified `gh-pages` branch of the repository
|
|
6
|
+
- **No complex continuous integration configuration**: This plugin pushes the build files to the specified `gh-pages` branch, so page updates take effect much faster.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i rspress-plugin-gh-pages
|
|
12
|
+
pnpm add rspress-plugin-gh-pages
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import * as path from 'path';
|
|
17
|
+
import { defineConfig } from 'rspress/config';
|
|
18
|
+
import ghPages from 'rspress-plugin-gh-pages';
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
root: path.join(__dirname, 'docs'),
|
|
22
|
+
plugins: [
|
|
23
|
+
ghpages({
|
|
24
|
+
repo: 'https://github.com/linbudu599/rspress-plugins.git',
|
|
25
|
+
branch: 'website',
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
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,9 +1,10 @@
|
|
|
1
1
|
import ghpages from 'gh-pages';
|
|
2
|
+
import type { MarkRequired } from 'rspress-plugin-devkit';
|
|
2
3
|
import type { RspressPlugin } from '@rspress/shared';
|
|
3
|
-
|
|
4
|
-
interface RspressPluginGHPagesOptions extends ghpages.PublishOptions {
|
|
4
|
+
interface RspressPluginGHPagesOptions extends MarkRequired<ghpages.PublishOptions, 'repo'> {
|
|
5
5
|
directory?: string;
|
|
6
6
|
silent?: boolean;
|
|
7
|
+
siteBase?: string;
|
|
7
8
|
}
|
|
8
|
-
export default function rspressPluginGHPages(options
|
|
9
|
+
export default function rspressPluginGHPages(options: RspressPluginGHPagesOptions): RspressPlugin;
|
|
9
10
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
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
|
-
import { PresetConfigMutator } from 'rspress-plugin-devkit';
|
|
6
|
-
export const componentsPath = path.join(__dirname, './components');
|
|
7
4
|
const DefaultDocBuildOutput = 'doc_build';
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const logPrefix = chalk.green('[gh-pages]');
|
|
6
|
+
export default function rspressPluginGHPages(options) {
|
|
7
|
+
const { repo, directory, branch = 'gh-pages', silent = false, siteBase = '', ...publishOptions } = options;
|
|
10
8
|
return {
|
|
11
9
|
name: 'rspress-plugin-gh-pages',
|
|
12
10
|
config(config) {
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
var _a;
|
|
12
|
+
let baseFromRepo = repo.includes('github.io')
|
|
13
|
+
? '/'
|
|
14
|
+
: (_a = /\/([^\/]+)\.git$/.exec(repo)) === null || _a === void 0 ? void 0 : _a[1];
|
|
15
|
+
// Use || here to as ?? will consider '' as a valid value
|
|
16
|
+
const base = siteBase || baseFromRepo || '';
|
|
17
|
+
if (!base) {
|
|
18
|
+
logger.warn(`${logPrefix} Failed to parse base from repo, site base path will not be updated.`);
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
config.base = `/${base}/`;
|
|
22
|
+
return config;
|
|
15
23
|
},
|
|
16
24
|
async afterBuild(config, isBuild) {
|
|
17
25
|
var _a;
|
|
26
|
+
if (!repo) {
|
|
27
|
+
logger.error(`Option ${chalk.cyan('repo')} is required for rspress-plugin-gh-pages.`);
|
|
28
|
+
}
|
|
18
29
|
if (!isBuild)
|
|
19
30
|
return;
|
|
20
31
|
const publishDir = (_a = directory !== null && directory !== void 0 ? directory : config.outDir) !== null && _a !== void 0 ? _a : DefaultDocBuildOutput;
|
|
21
|
-
const logPrefix = chalk.green('[rspress-plugin-gh-pages]');
|
|
22
32
|
if (!silent) {
|
|
23
33
|
logger.info(`${logPrefix} Publish directory: ${chalk.cyan(publishDir)}`);
|
|
24
34
|
logger.info(`${logPrefix} Publish branch: ${chalk.cyan(branch)}`);
|
package/doc_build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="generator" content="Rspress v1.17.1"><title data-rh="true">RSPress x GH Pages - Rspress x GHPages Example</title><script>{const e=localStorage.getItem("rspress-theme-appearance"),t=window.matchMedia("(prefers-color-scheme: dark)").matches,a=e&&"auto"!==e?"dark"===e:t;document.documentElement.classList.toggle("dark",a),document.documentElement.style.colorScheme=a?"dark":"light"}</script><title>Rspress x GHPages Example</title><script defer="defer" src="/
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="generator" content="Rspress v1.17.1"><title data-rh="true">RSPress x GH Pages - Rspress x GHPages Example</title><script>{const e=localStorage.getItem("rspress-theme-appearance"),t=window.matchMedia("(prefers-color-scheme: dark)").matches,a=e&&"auto"!==e?"dark"===e:t;document.documentElement.classList.toggle("dark",a),document.documentElement.style.colorScheme=a?"dark":"light"}</script><title>Rspress x GHPages Example</title><script defer="defer" src="/static/js/styles.5adf8b3b.js"></script><script defer="defer" src="/static/js/lib-lodash.03ab5c9a.js"></script><script defer="defer" src="/static/js/lib-polyfill.e7809649.js"></script><script defer="defer" src="/static/js/lib-react.548287ed.js"></script><script defer="defer" src="/static/js/lib-router.6f70bb88.js"></script><script defer="defer" src="/static/js/index.4ffb173e.js"></script><link href="/static/css/styles.178b55c4.css" rel="stylesheet"></head><body ><div id="root"><div><div class="navContainer_f6cde rspress-nav px-6 " style="position:sticky"><div class="container_f6cde flex justify-between items-center h-full"><div class="navBarTitle_f6cde"><a href="/" class="flex items-center w-full h-full text-base font-semibold transition-opacity duration-300 hover:opacity-60"><span>Rspress x GHPages Example</span></a></div><div class="undefined flex flex-1 justify-end items-center"><div class="rightNav_f6cde"><div class="flex sm:flex-1 items-center sm:pl-4 sm:pr-2"><div class="rspress-nav-search-button navSearchButton_6e282"><button><svg width="18" height="18" viewBox="0 0 32 32"><path fill="var(--rp-c-gray)" d="m29 27.586-7.552-7.552a11.018 11.018 0 1 0-1.414 1.414L27.586 29ZM4 13a9 9 0 1 1 9 9 9.01 9.01 0 0 1-9-9Z"></path></svg><p class="searchWord_6e282">Search Docs</p><div style="opacity:0"><span></span><span>K</span></div></button></div><div class="mobileNavSearchButton_6e282"><svg width="24" height="24" viewBox="0 0 32 32"><path fill="var(--rp-c-gray)" d="m29 27.586-7.552-7.552a11.018 11.018 0 1 0-1.414 1.414L27.586 29ZM4 13a9 9 0 1 1 9 9 9.01 9.01 0 0 1-9-9Z"></path></svg></div></div><div class="rspress-nav-menu menu h-14"></div><div class="flex-center flex-row"><div class="mx-2"><div class="md:mr-2 rspress-nav-appearance"><div class="p-1 border border-solid border-gray-300 text-gray-400 cursor-pointer rounded-md hover:border-gray-600 hover:text-gray-600 dark:hover:border-gray-200 dark:hover:text-gray-200 transition-all duration-300 w-7 h-7"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" class="dark:hidden" width="18" height="18" fill="currentColor"><path d="M12 18c-3.3 0-6-2.7-6-6s2.7-6 6-6 6 2.7 6 6-2.7 6-6 6zm0-10c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zM12 4c-.6 0-1-.4-1-1V1c0-.6.4-1 1-1s1 .4 1 1v2c0 .6-.4 1-1 1zM12 24c-.6 0-1-.4-1-1v-2c0-.6.4-1 1-1s1 .4 1 1v2c0 .6-.4 1-1 1zM5.6 6.6c-.3 0-.5-.1-.7-.3L3.5 4.9c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l1.4 1.4c.4.4.4 1 0 1.4-.1.2-.4.3-.7.3zM19.8 20.8c-.3 0-.5-.1-.7-.3l-1.4-1.4c-.4-.4-.4-1 0-1.4s1-.4 1.4 0l1.4 1.4c.4.4.4 1 0 1.4-.2.2-.5.3-.7.3zM3 13H1c-.6 0-1-.4-1-1s.4-1 1-1h2c.6 0 1 .4 1 1s-.4 1-1 1zM23 13h-2c-.6 0-1-.4-1-1s.4-1 1-1h2c.6 0 1 .4 1 1s-.4 1-1 1zM4.2 20.8c-.3 0-.5-.1-.7-.3-.4-.4-.4-1 0-1.4l1.4-1.4c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-1.4 1.4c-.2.2-.4.3-.7.3zM18.4 6.6c-.3 0-.5-.1-.7-.3-.4-.4-.4-1 0-1.4l1.4-1.4c.4-.4 1-.4 1.4 0s.4 1 0 1.4l-1.4 1.4c-.2.2-.5.3-.7.3z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" viewBox="0 0 24 24" class="hidden dark:block" width="18" height="18" fill="currentColor"><path d="M12.1 22h-.9c-5.5-.5-9.5-5.4-9-10.9.4-4.8 4.2-8.6 9-9 .4 0 .8.2 1 .5.2.3.2.8-.1 1.1-2 2.7-1.4 6.4 1.3 8.4 2.1 1.6 5 1.6 7.1 0 .3-.2.7-.3 1.1-.1.3.2.5.6.5 1-.2 2.7-1.5 5.1-3.6 6.8-1.9 1.4-4.1 2.2-6.4 2.2zM9.3 4.4c-2.9 1-5 3.6-5.2 6.8-.4 4.4 2.8 8.3 7.2 8.7 2.1.2 4.2-.4 5.8-1.8 1.1-.9 1.9-2.1 2.4-3.4-2.5.9-5.3.5-7.5-1.1-2.8-2.2-3.9-5.9-2.7-9.2z"></path></svg></div></div></div></div></div><div class="mobileNavMenu_f6cde"><div class="navScreen_457e8 " id="navScreen"><div class="container_457e8"><div class="navMenu_457e8"></div><div class="flex-center flex-col gap-2"><div class="mt-2 navAppearance_457e8 flex justify-center"></div></div></div></div><button aria-label="mobile hamburger" class=" navHamburger_e7b06 text-gray-500"><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="currentColor"><circle cx="8" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="16" r="2" fill="currentColor"></circle><circle cx="24" cy="16" r="2" fill="currentColor"></circle></svg></button></div></div></div></div><section><div class="docLayout_edeb4 pt-0"><div class="content_edeb4 rspress-doc-container flex flex-shrink-0 mx-auto"><div class="w-full flex-1"><div><div class="rspress-doc"><!--$--><h1 id="rspress-x-gh-pages" class="text-3xl mb-10 leading-10 tracking-tight title_3b154">RSPress x GH Pages<a class="link_3b154 header-anchor" aria-hidden="true" href="#rspress-x-gh-pages">#</a></h1><!--/$--></div><div class="rspress-doc-footer"><footer class="mt-8"><div class="xs:flex pb-5 px-2 justify-end items-center"></div><div class="flex flex-col"></div><div class="flex flex-col sm:flex-row sm:justify-around gap-4 pt-6"><div class="prev_e7091 flex flex-col"></div><div class="next_e7091 flex flex-col"></div></div></footer></div></div></div><div class="aside-container_edeb4"><div><div class="flex flex-col"><div class="hidden"><div id="aside-container" class="relative text-sm font-medium"><div class="leading-7 block text-sm font-semibold pl-3">ON THIS PAGE</div><nav class="mt-1"><ul class="relative"></ul></nav></div></div></div></div></div></div></div></section></div></div><div id="search-container"></div></body></html>
|