005 VuePress Theme Hope 主题样式演示
代码树
import { createApp } from "vue";
import App from "./App.vue";
createApp(App).mount("#app");<script setup>
import { ref } from "vue";
const msg = ref("Hello World!");
</script>
<template>
<h1>{{ msg }}</h1>
</template>{
"name": "demo",
"scripts": {
"dev": "vite"
}
}::: code-tree 项目文件 height="320px" entry="src/index.ts"
```ts title="src/index.ts"
import { createApp } from "vue";
import App from "./App.vue";
createApp(App).mount("#app");
```
```vue title="src/App.vue"
<script setup>
import { ref } from "vue";
const msg = ref("Hello World!");
</script>
<template>
<h1>{{ msg }}</h1>
</template>
```
```json title="package.json"
{
"name": "demo",
"scripts": {
"dev": "vite"
}
}
```
:::文件树
错误
目录树渲染貌似有问题,抽空给官方提 issue: https://github.com/vuepress-theme-hope/vuepress-theme-hope
::: file-tree my-blog 项目
- my-blog/ # 项目根目录
- src/ # 站点源码目录
- .vuepress/ # vuepress theme hope 主题配置
- styles/ # 样式目录
- config.scss # 主题变量(主题色等)
- palette.scss # 配色方案(换肤)
- index.scss # 自定义样式(写自己的 CSS)
- public/ # 静态资源目录(图片、图标,访问路径为 /xxx)
- config.ts # 站点总配置:语言、标题、部署路径、引入主题
- navbar.ts # 顶部导航栏配置
- siderbar.ts # 侧边栏配置
- theme.ts # 主题配置:外观、博客、Markdown、插件(最重要)
- demo/ # 功能演示页
- posts/ # 博客文章目录
- intro.md # 个人介绍页
- README.md # 站点首页(博客主页)
- .gitignore # git 忽略跟踪配置文件
- package.json # 项目依赖与启动脚本(pnpm install 就靠它)
- pnpm-lock.yaml # 自动生成的含依赖模块详情的文件
- pnpm-workspace.yaml # pnpm 专用配置(允许 esbuild 构建脚本运行)
- README.md # 项目 README
- tsconfig.json # TypeScript 配置(配置文件是 .ts 写的)
:::自定义对齐
古诗词赏析
阅尽天涯离别苦,不道归来,零落花如许。
花底相看无一语,绿窗春与天俱暮。
待把相思灯下诉,一缕新欢,旧恨千千缕。
最是人间留不住,朱颜辞镜花辞树。
王国维 - 《蝶恋花·阅尽天涯离别苦》
:::: info 古诗词赏析
::: center
阅尽天涯离别苦,不道归来,零落花如许。
花底相看无一语,绿窗春与天俱暮。
待把相思灯下诉,一缕新欢,旧恨千千缕。
最是人间留不住,朱颜辞镜花辞树。
:::
::: right
王国维 - 《蝶恋花·阅尽天涯离别苦》
:::选项卡
提示
选项卡 和 代码分组 类似,前者是通用容器,后者专门为代码块设计。用法一样。
选项卡官方文档: https://theme-hope.vuejs.press/zh/guide/markdown/content/tabs.html
代码分组官方文档: https://theme-hope.vuejs.press/zh/guide/markdown/code/code-tabs.html
- 普通选项卡
生当如夏花之绚烂,死当如秋叶之静美。
Let life be beautiful like summer flowers and death like autumn leaves.
::: tabs
@tab 中文简体
生当如夏花之绚烂,死当如秋叶之静美。
@tab English
Let life be beautiful like summer flowers and death like autumn leaves.- 多选项卡联动
- 安装 vuepress
npm i -D vuepresspnpm add -D vuepress- 安装 vuepress-theme-hope
npm i -D vuepress-theme-hopepnpm add -D vuepress-theme-hope- 安装 vuepress
::: code-tabs#install
@tab npm#npm
```shell
npm i -D vuepress
```
@tab:active pnpm#pnpm
```shell
pnpm add -D vuepress
```
:::
- 安装 vuepress-theme-hope
::: code-tabs#install
@tab npm
```shell
npm i -D vuepress-theme-hope
```
@tab:active pnpm
```shell
pnpm add -D vuepress-theme-hope
```
:::提示容器
重要
重要容器。
相关信息
信息容器。
注
注释容器。
提示
提示容器
注意
警告容器
警告
危险容器
展开查看详情
详情容器
::: important
重要容器。
:::
::: info
信息容器。
:::
::: note
注释容器。
:::
::: tip
提示容器
:::
::: warning
警告容器
:::
::: caution
危险容器
:::
::: details 展开查看详情
详情容器
:::图标渲染
提示
文档: https://theme-hope.vuejs.press/zh/guide/interface/icon.html
图标: https://icon-sets.iconify.design/
动态图标
静态图标
动态图标 ::svg-spinners:blocks-shuffle-3::
静态图标 ::noto-v1:whale::参数字段样式
wget 命令参数
HTTPS (SSL/TLS) 选项:
booleantrue只跟随安全的 HTTPS 链接
stringNone使用客户端证书文件
文件/散列值用于验证节点的公钥(PEM/DER)文件
#### wget 命令参数
##### HTTPS (SSL/TLS) 选项:
::: fields
@`--https-only` type=boolean required default=`true`
只跟随安全的 HTTPS 链接
@`--certificate` type=string optional default=`None`
使用客户端证书文件
@`--pinnedpubkey` type=`文件/散列值` deprecated
用于验证节点的公钥(PEM/DER)文件
:::流程步骤
创建 VuePress 项目
pnpm create vuepress-theme-hope my-docs安装依赖
pnpm install启动开发服务器
pnpm docs:dev
::: steps
1. 创建 VuePress 项目
```shell
pnpm create vuepress-theme-hope my-docs
```
2. 安装依赖
```shell
pnpm install
```
3. 启动开发服务器
```shell
pnpm docs:dev
```
:::