@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 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
- 本仓库已经内置 GitHub Pages 自动部署流程:
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
- 它会在推送到 `main` 分支时自动执行:
48
-
49
- 1. 进入 `template/`。
50
- 2. 执行 `npm ci` 安装模板依赖。
51
- 3. 使用 `BASE_PATH=/page-withu/ npm run build` 构建模板。
52
- 4. 上传 `template/dist/`。
53
- 5. 发布到 GitHub Pages。
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
- ```text
64
- https://explorer-dong.github.io/page-withu/
65
- ```
104
+ 如果仓库名不是用于根域名的 `用户名.github.io`,通常需要给构建命令设置子路径。例如仓库名是 `my-homepage`:
66
105
 
67
- 如果想手动触发部署,也可以在 GitHub Actions 页面选择 `Deploy Template to GitHub Pages`,然后点击 `Run workflow`。
106
+ ```yaml
107
+ - run: BASE_PATH=/my-homepage/ npm run build
108
+ ```
68
109
 
69
- ### 手动上传 dist
110
+ ### 方式二:手动上传 dist
70
111
 
71
112
  如果不想使用 GitHub Actions,也可以本地构建后手动上传 `dist/`。
72
113
 
73
114
  ```bash
74
- cd template
75
- BASE_PATH=/page-withu/ npm run build
115
+ npm run build
76
116
  ```
77
117
 
78
- 然后把 `template/dist/` 内容上传到用于 GitHub Pages 的发布分支或目录。
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.0",
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/",
@@ -0,0 +1,10 @@
1
+ node_modules/
2
+ dist/
3
+
4
+ .env
5
+ .env.*
6
+ !.env.example
7
+ *.local
8
+
9
+ .DS_Store
10
+ .idea/