@x-withu/page-withu 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/bin/page-withu.js +1 -1
- package/docs/deploy.md +57 -17
- package/package.json +2 -1
- package/template/.gitignore +10 -0
package/bin/page-withu.js
CHANGED
|
@@ -15,7 +15,7 @@ const __dirname = path.dirname(__filename);
|
|
|
15
15
|
const templateDir = path.resolve(__dirname, '../template');
|
|
16
16
|
const manifestName = '.page-withu.json';
|
|
17
17
|
const managedRoots = ['src'];
|
|
18
|
-
const managedFiles = ['index.html', 'vite.config.js'];
|
|
18
|
+
const managedFiles = ['.gitignore', 'index.html', 'vite.config.js'];
|
|
19
19
|
|
|
20
20
|
const program = new Command();
|
|
21
21
|
|
package/docs/deploy.md
CHANGED
|
@@ -38,19 +38,60 @@ npm run preview
|
|
|
38
38
|
|
|
39
39
|
## 部署到 GitHub Pages
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
GitHub Pages 适合把你生成好的个人主页托管到 GitHub 仓库中。
|
|
42
|
+
|
|
43
|
+
### 方式一:使用 GitHub Actions 自动部署
|
|
44
|
+
|
|
45
|
+
在你自己的主页项目中创建部署工作流:
|
|
42
46
|
|
|
43
47
|
```text
|
|
44
48
|
.github/workflows/deploy-pages.yml
|
|
45
49
|
```
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
示例内容:
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
name: Deploy to GitHub Pages
|
|
55
|
+
|
|
56
|
+
on:
|
|
57
|
+
push:
|
|
58
|
+
branches: [main]
|
|
59
|
+
workflow_dispatch:
|
|
60
|
+
|
|
61
|
+
permissions:
|
|
62
|
+
contents: read
|
|
63
|
+
pages: write
|
|
64
|
+
id-token: write
|
|
65
|
+
|
|
66
|
+
concurrency:
|
|
67
|
+
group: pages
|
|
68
|
+
cancel-in-progress: false
|
|
69
|
+
|
|
70
|
+
jobs:
|
|
71
|
+
build:
|
|
72
|
+
runs-on: ubuntu-latest
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v4
|
|
75
|
+
- uses: actions/setup-node@v4
|
|
76
|
+
with:
|
|
77
|
+
node-version: 20
|
|
78
|
+
cache: npm
|
|
79
|
+
- run: npm ci
|
|
80
|
+
- run: npm run build
|
|
81
|
+
- uses: actions/upload-pages-artifact@v3
|
|
82
|
+
with:
|
|
83
|
+
path: dist
|
|
84
|
+
|
|
85
|
+
deploy:
|
|
86
|
+
needs: build
|
|
87
|
+
runs-on: ubuntu-latest
|
|
88
|
+
environment:
|
|
89
|
+
name: github-pages
|
|
90
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
91
|
+
steps:
|
|
92
|
+
- id: deployment
|
|
93
|
+
uses: actions/deploy-pages@v4
|
|
94
|
+
```
|
|
54
95
|
|
|
55
96
|
首次使用前,需要在 GitHub 仓库中打开:
|
|
56
97
|
|
|
@@ -58,24 +99,23 @@ npm run preview
|
|
|
58
99
|
Settings → Pages → Build and deployment → Source → GitHub Actions
|
|
59
100
|
```
|
|
60
101
|
|
|
61
|
-
配置完成后,每次推送到 `main`
|
|
102
|
+
配置完成后,每次推送到 `main` 分支都会自动构建并发布你的站点。
|
|
62
103
|
|
|
63
|
-
|
|
64
|
-
https://explorer-dong.github.io/page-withu/
|
|
65
|
-
```
|
|
104
|
+
如果仓库名不是用于根域名的 `用户名.github.io`,通常需要给构建命令设置子路径。例如仓库名是 `my-homepage`:
|
|
66
105
|
|
|
67
|
-
|
|
106
|
+
```yaml
|
|
107
|
+
- run: BASE_PATH=/my-homepage/ npm run build
|
|
108
|
+
```
|
|
68
109
|
|
|
69
|
-
###
|
|
110
|
+
### 方式二:手动上传 dist
|
|
70
111
|
|
|
71
112
|
如果不想使用 GitHub Actions,也可以本地构建后手动上传 `dist/`。
|
|
72
113
|
|
|
73
114
|
```bash
|
|
74
|
-
|
|
75
|
-
BASE_PATH=/page-withu/ npm run build
|
|
115
|
+
npm run build
|
|
76
116
|
```
|
|
77
117
|
|
|
78
|
-
然后把 `
|
|
118
|
+
然后把 `dist/` 内容上传到用于 GitHub Pages 的发布分支或目录。
|
|
79
119
|
|
|
80
120
|
## 部署到 Cloudflare Pages
|
|
81
121
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-withu/page-withu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A lightweight, elegant personal homepage generator.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"template/content/",
|
|
17
17
|
"template/src/",
|
|
18
18
|
"template/index.html",
|
|
19
|
+
"template/.gitignore",
|
|
19
20
|
"template/package.json",
|
|
20
21
|
"template/vite.config.js",
|
|
21
22
|
"docs/",
|