00:00:00
搭建个人博客
🎎 VitePress
VitePress 是一个 静态站点生成器(SSG),专为构建快速、以内容为中心的站点而设计。简而言之,VitePress 获取用 Markdown 编写的内容,对其应用主题,并生成可以轻松部署到任何地方的静态 HTML 页面。
🍨 前置准备
👑 安装命令
bash
pnpm add -D vitepress@nextVitePress 附带一个命令行设置向导,可以帮助你构建一个基本项目。安装后,通过运行以下命令启动向导:
bash
pnpm vitepress init按照提示回答几个问题:
bash
┌ Welcome to VitePress!
│
◇ Where should VitePress initialize the config?
│ ./docs
│
◇ Where should VitePress look for your markdown files?
│ ./docs
│
◇ Site title:
│ My Awesome Project
│
◇ Site description:
│ A VitePress Site
│
◇ Theme:
│ Default Theme
│
◇ Use TypeScript for config and theme files?
│ Yes
│
◇ Add VitePress npm scripts to package.json?
│ Yes
│
◇ Add a prefix for VitePress npm scripts?
│ Yes
│
◇ Prefix for VitePress npm scripts:
│ docs
│
└ Done! Now run pnpm run docs:dev and start writing.🚎 启动并运行
还应将如下脚本注入到 package.json 中:
bash
{
...
"scripts": {
"dev": "vitepress dev docs",
"build": "git fetch --unshallow && vitepress build docs",
"preview": "vitepress preview docs"
},
...
}使用以下命令运行它:
bash
pnpm run dev开发服务应该会运行在 http://localhost:5173 上。在浏览器中访问 URL 以查看新站点的运行情况吧! 
🛶 界面展示

