• Welcome to Journal web site.

我是 PHP 程序员

- 开发无止境 -

Next
Prev

VuePress 主题

Data: 2016-07-28 11:14:29Form: JournalClick: 11

# 主题

  • 使用一个主题和使用一个插件的方式几乎一致。

# 一、主题使用说明

  • 引用主题
// config.js 文件
module.exports = {
    theme: 'vuepress-theme-xx'
}
  • 主题名以 vuepress-theme- 开头,可以省略
// config.js 文件
module.exports = {
    theme: 'xxx'
}
  • 备:以 @vuepress/theme- 开头的主题是官方维护的主题。

# 二、官方(博客)主题

# 1、创建 blog 目录

├── docs
├── blog
│   ├── _posts (存储您的帖子内容)
│   │   ├── 2018-11-7-frontmatter-in-vuepress.md
│   │   ├── 2019-2-26-markdown-slot.md
│   │   └── 2019-5-6-writing-a-vuepress-theme.md
│   └── .vuepress
│       ├── `components` (可选的)
│       ├── `public` (可选的)
│       ├── `styles` (可选的)
│       │   ├── index.styl
│       │   └── palette.styl
│       ├── config.js
│       └── `enhanceApp.js` (可选的)
└── package.json

# 2、安装

yarn add @vuepress/theme-blog -D
# OR npm install @vuepress/theme-blog -D

# 3、配置

  • 创建 config.js 文件
module.exports = {
    title: "欧阳克个人博客",
    theme: "@vuepress/theme-blog",
    themeConfig: {},
};

# 4、项目脚本配置

// package.json
"scripts": {
    "dev": "vuepress dev blog",
    "build": "vuepress build blog"
}

# 5、运行

yarn dev
# npm run dev

# 6、写个帖子

  • 创建 _posts/1.md 目录和文件
  • 可以随意命名文件,但建议在前面加上日期。它可以帮助帖子组织并默认用作永久链接。
# VuePress

- 官网:https://www.vuepress.cn
- `VuePress``Vue` 驱动的静态网站生成器

---

## 一、介绍

- 简洁至上
  - 以 Markdown 为中心的项目结构,以最少的配置帮助你专注于写作。
- `Vue` 驱动
  - 享受 `Vue` + `webpack` 的开发体验,可以在 `Markdown` 中使用 `Vue` 组件,又可以使用 `Vue` 来开发自定义主题。
- 高性能
  - `VuePress` 会为每个页面预渲染生成静态的 `HTML`,同时,每个页面被加载的时候,将作为 `SPA` 运行。

---

## 二、安装 `Node.js`

- `VuePress` 需要 `Node.js` >= 8.6
- 官网:https://nodejs.org

---

## 三、安装 `VuePress`

### 1、创建并进入一个新目录

```php
mkdir vuepress-starter && cd vuepress-starter
```

### 2、包管理器进行初始化

```php
yarn init # npm init
```

```php
# 项目名称
question name (vuepress):
# 项目版本
question version (1.0.0):
# 项目描述
question description:
# 项目入口
question entry point (index.js):
# 项目存储库,如:git
question repository url:
# 项目作者
question author:
# 项目许可证
question license (MIT):
# 项目私有属性
question private:
```

- 根目录会新建一个文件:package.json

### 3、将 `VuePress` 安装为本地依赖

```php
yarn add -D vuepress # npm install -D vuepress
yarn global add vuepress # 或者:npm install -g vuepress
```

### 4、新建目录和文件

```php
mkdir docs && echo '# Hello VuePress' > docs/README.md
```

### 5、`package.json` 添加配置

```php
{
    "scripts": {
        "docs:dev": "vuepress dev docs",
        "docs:build": "vuepress build docs"
    }
}
```

### 6、本地启动服务器

```php
yarn docs:dev # npm run docs:dev
```

# 7、设置帖子信息

  • 每个帖子设置
---
title: VuePress
date: 2021-06-18
author: 欧阳克
location: He Fei
---

# 8、设置 tags

---
title: VuePress
date: 2021-06-18
author: 欧阳克
location: He Fei
tags:
  - VuePress
  - Vue
---

# 三、更多主题

  • github:Awesome VuePressopen in new window

插件

Name:
<提交>