https://www.vuepress.cn/guide/getting-started.html
mkdir vuepress-starter && cd vuepress-starter
npm init // npm init -y (-y免去确认)
npm install -D vuepress
mkdir docs && echo '# Hello VuePress' > docs/README.md
{
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}
}
npm run docs:dev
VuePress 会在 http://localhost:8080 (opens new window)启动一个热重载的开发服务器。
├── docs
│ ├── .vuepress (可选的)
│ │ ├── components (可选的)
│ │ ├── theme (可选的)
│ │ │ └── Layout.vue
│ │ ├── public (可选的)
│ │ ├── styles (可选的)
│ │ │ ├── index.styl
│ │ │ └── palette.styl
│ │ ├── templates (可选的, 谨慎配置)
│ │ │ ├── dev.html
│ │ │ └── ssr.html
│ │ ├── config.js (可选的)
│ │ └── enhanceApp.js (可选的)
│ │
│ ├── README.md
│ ├── guide (一般用户都在这个目录下创建网站指南,当然可以不用)
│ │ └── README.md (指南里面的具体内容)
│ └── config.md
│
└── package.json 项目初始化时,根目录下自动生成的配置文件,定义了项目的基本配置信息及需要依赖的各个模块、指定运行脚本命令的npm命令行缩写等。
https://www.vuepress.cn/theme/default-theme-config.html#%E9%A6%96%E9%A1%B5
.md 其实就是看到的页面
我们看到的首页,是通过配置根路径下的README.md文件实现的、而一些,导航栏、侧边栏,则是通过配置docs/config.js实现。
将docs目录下的README.md中的内容替换,并在public目录下放置一张图片,再次启动。
注:根路径默认的README.md,会被编译成index.html文件。
---
home: true
heroImage: /hero.png
heroText: Hero 标题
tagline: Hero 副标题
actionText: 快速上手 →
actionLink: /zh/guide/
features:
- title: 简洁至上
details: 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。
- title: Vue驱动
details: 享受 Vue + webpack 的开发体验,在 Markdown 中使用 Vue 组件,同时可以使用 Vue 来开发自定义主题。
- title: 高性能
details: VuePress 为每个页面预渲染生成静态的 HTML,同时在页面被加载的时候,将作为 SPA 运行。
footer: MIT Licensed | Copyright © 2018-present Evan You
---
新建目录
├─── docs
│ ├── README.md
│ └── .vuepress
│ ├── public
│ └── config.js
└── package.json
logo.png存放到public文件夹下,在config.js中
module.exports = {
// 网站的一些基本配置
// base:配置部署站点的基础路径,后续再介绍
title: 'xxx', // 网站的标题
description: 'xxxxx', // 网站xxx的描述,它将会以 标签渲染到当前页面的 HTML 中。
head: [
['link', { rel: 'icon', href: '/logo.png' }] // 需要被注入到当前页面的 HTML 中的标签
],
}
在config.js中themeConfig 是关于导航栏的设置
├─── docs
│ ├── README.md
│ └── .vuepress
│ ├── public
│ └── config.js
│ └── blog
│ ├── backend
│ ├── README.md
│ └── fontend
│ ├── README.md
└── package.json
```typescript
themeConfig: {
logo: '/dh_logo.jpg',
nav: [
{ text: 'Home', link: '/' },
// 可指定链接跳转模式:默认target: '_blank'新窗口打开,_self当前窗口打开
// 这里一定记得最后一个/
{ text: '前端', link: '/blog/fontend/' },
{ text: '后端', link: '/blog/backend/'},
]
}
在config.js中 themeConfig.sidebar: ‘auto’

https://www.vuepress.cn/guide/markdown.html
https://blog.csdn.net/xiaoxianer321/article/details/119548202