Commands
Valaxy 内置了辅助命令行,你可使用 valaxy
或缩写 vala
来执行以下命令。
Valaxy has a commandline tool. You can use valaxy
or vala
to execute the following commands.
valaxy [args]
Commands:
valaxy [root] Start a local server for Valaxy [default]
valaxy build [root] build your blog to static content
valaxy rss [root] generate rss feed
valaxy new <title> Draft a new post
Positionals:
root root folder of your source files [string] [default: "."]
Options:
-p, --port port [number]
-o, --open open in browser [boolean] [default: false]
--remote listen public host and enable remote control
[boolean] [default: true]
--log log level
[string] [choices: "error", "warn", "info", "silent"] [default: "info"]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
使用
Usage
局部使用
Local
你可以在项目的 package.json
中配置快捷脚本。(推荐)
You can configure shortcut scripts in package.json
. (Suggested)
{
"scripts": {
"build": "npm run build:ssg",
"build:spa": "valaxy build",
"build:ssg": "valaxy build --ssg",
"dev": "valaxy .",
"new": "valaxy new",
"rss": "valaxy rss"
}
}
譬如通过 npm run dev
启动项目,通过 npm run build
可以在构建生成 ssg 站点后,再构建 RSS 源。 通过 pnpm new post-title
在 posts
文件夹下新建一个名为 post-title
的文章。
For example, you can use npm run dev
to run the project, use npm run build
to build SSG site followed by building RSS source, and use pnpm new post-title
to create a new post called post-title
under the posts
folder.
全局安装
Global
你也可以全局安装 valaxy 以在全局使用 valaxy
命令。(非必须)
You can also install Valaxy globally to use valaxy
command globally. (Optional)
pnpm add -g valaxy
常用命令
Useful Commands
valaxy .
: 启动 Valaxy,默认目录为当前目录(.
可不写)valaxy rss
: 自动生成 RSSvalaxy build
: 默认采用 Vite 构建 SPA 应用valaxy build --ssg
: 使用 vite-ssg 构建静态页面站点(SEO 友好,推荐)
valaxy .
: Start Valaxy. The default directory is current directory. (.
is optional)valaxy rss
: Generate RSSvalaxy build
: Use Vite to build SPA app by defaultvalaxy build --ssg
: Use vite-ssg to build static web page (SEO-friendly, recommended)
文章
Posts
valaxy new <title>
: 在pages/posts
目录下新建标题为title
的帖子(.md)
譬如,valaxy new your-first-post
,将会在 pages/posts
下自动新建 your-first-post.md
文件,并附带日期。
你觉得还可以有其他更常用、更好用的命令?没问题,尽管来 Issues 反馈吧!
valaxy new <title>
: Create a post (.md) titledtitle
under the directorypages/posts
.
For example, valaxy new your-first-post
will create a file your-first-post.md
under pages/posts
, and update the date.
Do you think you have other more useful or better commands? That’s great! Please report that by creating an issue at GitHub Issues!
FAQ
控制台开发时日志太少,构建时日志太多?
More logs when developing and less when building?
- 开发与(
valaxy
)构建(valaxy build
)时默认日志等级为info
- 可选项:['error', 'warn', 'info', 'silent']
您可以通过设置日志等级控制。
譬如 valaxy build --log=warn
。
- The default log level is
info
when developing (valaxy
) and building (valaxy build
). - Options: ['error', 'warn', 'info', 'silent']
You can use arguments to set the log level.
For example, valaxy build --log=info
.
怀念 Hexo 的 hexo deploy
?
Miss hexo deploy
from Hexo?
在创建 Valaxy 项目时,已内置了 .github/workflows/gh-pages.yml
,在推送至 GitHub 时,会自动构建并部署到 GitHub Pages。
如果你仅想部署 gh-pages
分支,并且真的很想使用 deploy
。 你也可以安装 pnpm add -D gh-pages
,并在项目的 package.json
中配置快捷脚本。
{
"scripts": {
"deploy": "valaxy build && gh-pages -d dist"
},
"devDependencies": {
"gh-pages": "latest"
}
}
When you create a Valaxy project, a .github/workflows/gh-pages.yml
file is included. When you push to GitHub, it will automatically build and deploy to GitHub Pages.
If you only want to deploy the gh-pages
branch and really want to use deploy
.
You can also install pnpm add -D gh-pages
and configure shortcut scripts in package.json
.
{
"scripts": {
"deploy": "valaxy build && gh-pages -d dist"
},
"devDependencies": {
"gh-pages": "latest"
}
}