3.5 KiB
3.5 KiB
title, author, icon, createTime, permalink, tags
| title | author | icon | createTime | permalink | tags | ||
|---|---|---|---|---|---|---|---|
| 安装/使用 | pengzhanbo | grommet-icons:install | 2024/03/04 09:50:07 | /guide/quick-start/ |
|
依赖环境
::: info 提示
- 使用 pnpm 时,你需要安装
vue作为 peer-dependencies 。 - 使用 Yarn 2+ 时,你需要在
.yarnrc.yml文件中设置nodeLinker: 'node-modules'。 :::
安装
使用本主题,你需要首先新建一个项目,并安装vuepress@next以及本主题
:::: steps
-
新建文件夹并进入目录
mkdir my-blog cd my-blog -
初始化项目
::: code-tabs @tab pnpm
git init pnpm init@tab yarn
git init yarn init@tab npm
git init npm init:::
-
安装相关依赖
安装
vuepress@next和vuepress-theme-plume作为本地依赖。::: code-tabs @tab pnpm
# 安装 vuepress pnpm add -D vuepress@next vue # 安装 主题和打包工具 pnpm add -D vuepress-theme-plume @vuepress/bundler-vite@next@tab yarn
# 安装 vuepress yarn add -D vuepress@next # 安装 主题和打包工具 yarn add -D vuepress-theme-plume @vuepress/bundler-vite@next@tab npm
# 安装 vuepress npm i -D vuepress@next # 安装 主题和打包工具 npm i -D vuepress-theme-plume @vuepress/bundler-vite@next:::
:::warning 主题当前版本 已适配至
vuepress@2.0.0-rc.14,你应该安装这个版本的 VuePress。 高于或低于这个版本,可能会存在潜在的兼容性问题。 ::: -
在
package.json中添加script::: code-tabs @tab package.json
{ "scripts": { "dev": "vuepress dev docs", "build": "vuepress build docs" } }:::
vuepress默认将文档源码放在docs目录下。 -
将默认的临时目录和缓存目录添加到
.gitignore文件中::: code-tabs @tab .gitignore
node_modules .temp .cache@tab sh
echo 'node_modules' >> .gitignore echo '.temp' >> .gitignore echo '.cache' >> .gitignore:::
-
在
docs/.vuepress/config.{js,ts}中配置主题::: code-tabs @tab docs/.vuepress/config.js
import { defineUserConfig } from 'vuepress' import { viteBundler } from '@vuepress/bundler-vite' import { plumeTheme } from 'vuepress-theme-plume' export default defineUserConfig({ // 请不要忘记设置默认语言 lang: 'zh-CN', theme: plumeTheme({ // more... }), bundler: viteBundler(), }):::
:::warning 无论是否需要使用 多语言 ,你都应该为 VuePress 配置 正确
lang选项值。 主题需要根据lang选项来确定语言环境文本。 ::: -
在
docs目录下新建README.md文件声明首页配置。 ::: code-tabs @tab README.md
--- home: true ---:::
-
在本地服务器启动你的文档站点
::: code-tabs @tab pnpm
pnpm dev@tab yarn
yarn dev@tab npm
npm run dev:::
Vuepress 会在 http://localhost:8080 。启动一个热重载的开发服务器。当你修改你的 Markdown 文件时,浏览器中的内容也会自动更新。
-
完成
::::