Skip to content

Commit

Permalink
Merge 360c87f into f9006bd
Browse files Browse the repository at this point in the history
  • Loading branch information
zyao89 committed Jan 5, 2020
2 parents f9006bd + 360c87f commit 635a49e
Show file tree
Hide file tree
Showing 40 changed files with 1,097 additions and 294 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
uses: JamesIves/github-pages-deploy-action@master
env:
GAID: ${{ secrets.GAID }}
GITHUB_CLIENT_ID: ${{ secrets.GITHUB_CLIENT_ID }}
GITHUB_CLIENT_SECRET: ${{ secrets.GITHUB_CLIENT_SECRET }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/.vuepress/dist
Expand Down
24 changes: 21 additions & 3 deletions bin/micro-app-vuepress
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
#!/usr/bin/env node
'use strict';

process.env.MICRO_APP_VUEPRESS_RUNNING = true;

process.env.MICRO_APP_VUEPRESS_DIRECT_RUNNING = true;
const yParser = require('yargs-parser');
const argv = yParser(process.argv.slice(2));
const { service } = require('@micro-app/cli');
const path = require('path');

const { tryRequire, logger, execa } = require('@micro-app/shared-utils');
let MicroAppCLI = tryRequire('@micro-app/cli');
if (!MicroAppCLI) {
logger.info('[auto]', 'npm install @micro-app/cli');
const { exitCode, stderr } = execa.sync('npm', [ 'install', '@micro-app/cli', '--no-save', '--no-package-lock' ], {
cwd: process.cwd(),
stdio: 'inherit',
});
if (exitCode) {
logger.throw(stderr);
}
const importFresh = require('import-fresh'); // 依赖 @micro-app/shared-utils
MicroAppCLI = importFresh('@micro-app/cli');
}
if (!MicroAppCLI) {
logger.throw("Cannot find module '@micro-app/cli'!");
}

const { service } = MicroAppCLI;

[ 'extends', 'commands' ].forEach(name => {
service.registerPlugin({
id: `cli:plugin-extend-vuepress-${name}`,
Expand Down
3 changes: 0 additions & 3 deletions docs/__tests/snippet.js

This file was deleted.

35 changes: 35 additions & 0 deletions docs/zh/config/comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 评论

配置评论组件。

## Introduce

通过 `comment` 配置评论组件, 暂时只支持 `vssue`

## Usage

使用方式如下:

```js
// micro-app.vuepress.config.js
module.exports = {
comment: {
type: 'vssue', // default: vssue
platform: 'github', // default: github
// 其他的 Vssue 配置
owner: 'OWNER_OF_REPO',
repo: 'NAME_OF_REPO',
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
}
}
```

## Options

### type

- 类型: `string`
- 默认值: `vssue`

选择评论组件类型。
27 changes: 27 additions & 0 deletions docs/zh/config/google-analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Google Analytics

配置 `Google Analytics` 参数。

## Usage

使用方式如下:

```js
// micro-app.vuepress.config.js
module.exports = {
GAID: '' // UA-00000000-0
}
```

**参考:**

- [plugin-google-analytics](https://v1.vuepress.vuejs.org/zh/plugin/official/plugin-google-analytics.html)

## Options

### GAID

- 类型: `string`
- 默认值: `undefined`

提供 Google Analytics ID 以启用集成。
33 changes: 33 additions & 0 deletions docs/zh/config/redirect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 重定向

配置评论组件。

## Introduce

VuePress 内置了多语言系统,但你必须提供一个默认语言,否则直接访问 `/` 将只能得到 404。
然而,提供默认语言往往又意味着不那么友好的项目结构(因为默认语言下的文件会比其他语言低一级),我们有时也希望网站保留 `/` 用于更加智能地重定向(比如根据 `navigator.language` 判断用户所使用的语言自动定向到相关页面)。
`vuepress-plugin-redirect` 就是这样一个自动重定向的插件。当然,它所能做的事情不止是自动匹配语言,你可以通过定制你的重定向器实现任何页面到子页面的重定向。

因此我们再多语言时,集成了此插件。

## Usage

使用方式如下:

```js
// micro-app.vuepress.config.js
module.exports = {
redirect: false // default: true
}
```

## Options

### redirect

- 类型: `boolean | Object`
- 默认值: `true`

当参数为 `false` 时,禁用该插件。

当参数为一个对象时,请参考:[vuepress-plugin-redirect](https://vuepress.github.io/zh/plugins/redirect/)
17 changes: 11 additions & 6 deletions docs/zh/config/svg-icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,30 @@ module.exports = {
| author | `<SvgIcon name="author"/>` | <SvgIcon name="author"/> |
| beian | `<SvgIcon name="beian"/>` | <SvgIcon name="beian"/> |
| category | `<SvgIcon name="category"/>` | <SvgIcon name="category"/> |
| copy | `<SvgIcon name="copy"/>` | <SvgIcon name="copy"/> |
| copyright | `<SvgIcon name="copyright"/>` | <SvgIcon name="copyright"/> |
| date | `<SvgIcon name="date"/>` | <SvgIcon name="date"/> |
| doc | `<SvgIcon name="doc"/>` | <SvgIcon name="doc"/> |
| friend | `<SvgIcon name="friend"/>` | <SvgIcon name="friend"/> |
| github | `<SvgIcon name="github"/>` | <SvgIcon name="github"/> |
| link | `<SvgIcon name="link"/>` | <SvgIcon name="link"/> |
| tags | `<SvgIcon name="tags"/>` | <SvgIcon name="tags"/> |
| zap | `<SvgIcon name="zap"/>` | <SvgIcon name="zap"/> |
| home | `<SvgIcon name="home"/>` | <SvgIcon name="home"/> |
| package | `<SvgIcon name="package"/>` | <SvgIcon name="package"/> |
| guide | `<SvgIcon name="guide"/>` | <SvgIcon name="guide"/> |
| help | `<SvgIcon name="help"/>` | <SvgIcon name="help"/> |
| home | `<SvgIcon name="home"/>` | <SvgIcon name="home"/> |
| info | `<SvgIcon name="info"/>` | <SvgIcon name="info"/> |
| doc | `<SvgIcon name="doc"/>` | <SvgIcon name="doc"/> |
| link | `<SvgIcon name="link"/>` | <SvgIcon name="link"/> |
| more | `<SvgIcon name="more"/>` | <SvgIcon name="more"/> |
| package | `<SvgIcon name="package"/>` | <SvgIcon name="package"/> |
| rss | `<SvgIcon name="rss"/>` | <SvgIcon name="rss"/> |
| run | `<SvgIcon name="run"/>` | <SvgIcon name="run"/> |
| tags | `<SvgIcon name="tags"/>` | <SvgIcon name="tags"/> |
| zap | `<SvgIcon name="zap"/>` | <SvgIcon name="zap"/> |

使用方式如下:

```vue
<SvgIcon name="tags"/>
<SvgIcon name="tags" size="20"/>
<SvgIcon name="tags" size="32"/>
```

## Options
Expand Down
6 changes: 6 additions & 0 deletions docs/zh/guide/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
title: 介绍
tag:
- abc
---

# 介绍

`@micro-app/plugin-vuepress` 只是作为 `VuePress` 的增强,用于 `@micro-app` 系列的文档输出插件。
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/guide/deep/global-computed.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@

所有文章列表。

## $tagPosts
## $postsForTags

所有标签文章列表。

## $categoriePosts
## $postsForCategories

所有分类文章列表。

Expand Down
2 changes: 1 addition & 1 deletion micro-app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const config = {};

// 兼容两种启动方式
if (!process.env.MICRO_APP_VUEPRESS_RUNNING) {
if (!process.env.MICRO_APP_VUEPRESS_DIRECT_RUNNING) {
config.plugins = [ __dirname ];
}

Expand Down
14 changes: 10 additions & 4 deletions micro-app.vuepress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
selectText: '选择语言',
ariaLabel: '选择语言',
editLinkText: '在 GitHub 上编辑此页',
lastUpdated: '上次更新',
lastUpdated: '上次编辑时间',
repoLabel: '查看源码',
sidebar: getSidebar('zh'),
nav: getNav('zh'),
},
Expand All @@ -26,10 +27,7 @@ module.exports = {
// },
},

lastUpdated: '上次编辑时间',
repoLabel: '查看源码',
repoIcon: 'github',
editLinkText: '在 GitHub 上编辑此页',
// 假定是 GitHub. 同时也可以是一个完整的 GitLab URL
repo: 'MicroAppJS/plugin-vuepress',
// 自定义仓库链接文字。默认从 `themeConfig.repo` 中自动推断为
Expand Down Expand Up @@ -75,6 +73,14 @@ module.exports = {
repo: 'git@github.com:MicroAppJS/plugin-vuepress.git',
branch: 'gh-pages',
},

comment: {
type: 'vssue', // default: vssue
owner: 'MicroAppJS',
repo: 'plugin-vuepress',
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
},
};

function getSidebar(lang = 'zh') {
Expand Down
19 changes: 14 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@micro-app/plugin-vuepress",
"version": "0.0.1",
"version": "0.0.4",
"description": "[Plugin] adapter vuepress plugin.",
"main": "src/index.js",
"bin": {
Expand All @@ -14,6 +14,7 @@
},
"files": [
"bin",
"scripts",
"src",
"theme"
],
Expand Down Expand Up @@ -43,20 +44,28 @@
},
"devDependencies": {
"@micro-app/cli": "^0.3.0-alpha.2",
"@types/jest": "^24.0.24",
"@types/jest": "^24.0.25",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-config-2o3t": "^1.1.17",
"jest": "^24.9.0"
},
"dependencies": {
"@micro-app/shared-utils": "^0.1.10",
"@micro-app/shared-utils": "^0.1.11",
"@vssue/api-github-v3": "^1.1.2",
"@vssue/api-github-v4": "^1.2.1",
"@vssue/vuepress-plugin-vssue": "^1.3.0",
"@vuepress/plugin-back-to-top": "^1.2.0",
"@vuepress/plugin-blog": "^1.6.1",
"@vuepress/plugin-blog": "^1.7.0",
"@vuepress/plugin-google-analytics": "^1.2.0",
"@vuepress/plugin-medium-zoom": "^1.2.0",
"@vuepress/plugin-pwa": "^1.2.0",
"remove-markdown": "^0.3.0",
"clipboard": "^2.0.4",
"markdown-it-footnote": "^3.0.2",
"markdown-it-mark": "^3.0.0",
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"moment": "^2.24.0",
"svg-sprite-loader": "^4.1.6",
"svgo": "^1.3.2",
"svgo-loader": "^2.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deploy/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(api, argv, opts) {
logger.throw('[VuePress > Deploy > Github]', '必须在 micro-app.vuepress.config.js 中声明 deploy: {} !');
}

let repo = deployOpts.repo || false;
let repo = deployOpts.repo || selfVuepressConfig.repo || false;
if (!_.isString(repo)) {
logger.throw('[VuePress > Deploy > Github]', 'deploy.repo must be string!');
}
Expand Down
15 changes: 12 additions & 3 deletions theme/components/BlogPosts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
<div :class="$style.posts" ref="postsRef">
<slot name="top"></slot>

<div v-for="post in currentPosts" :key="post.key" :class="$style.post">
<TransitionFadeSlide
tag="div"
direction="x"
:delay="0.2 * index"
v-for="{post, index} in currentPosts"
:key="post.key"
:class="$style.post"
>
<h2 :class="$style.title">
<NavLink :item="post.path">{{ post.title }}</NavLink>
</h2>
<article :class="$style.summary">
{{ post.frontmatter.summary || post.summary }}
{{ post.frontmatter.summary || '' }}
<!-- <Content :post-key="post.key" slot-key="summary" /> -->
</article>
<PageInfo :class="$style.info" :info="post" hideTitle />
</div>
</TransitionFadeSlide>

<!-- 分页 -->
<div :class="$style.pagation">
Expand All @@ -31,12 +38,14 @@
import NavLink from '@theme/components/NavLink.vue';
import PageInfo from '@theme/components/PageInfo.vue';
import Pagination from '@theme/components/Pagination.vue';
import TransitionFadeSlide from '@theme/components/TransitionFadeSlide.vue';
export default {
name: 'BlogPosts',
components: {
NavLink,
PageInfo,
Pagination,
TransitionFadeSlide,
},
props: {
posts: {
Expand Down
29 changes: 29 additions & 0 deletions theme/components/Comment.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<div :class="$style.root" v-if="visible">
<Vssue v-if="type === 'vssue'" />
</div>
</template>

<script>
export default {
name: 'Comment',
computed: {
visible() {
return !!this.$themeConfig.comment;
},
comment() {
return this.$themeConfig.comment || {};
},
type() {
return this.comment.type || 'vssue';
},
},
};
</script>

<style lang="stylus" module>
.root {
max-width: 820px;
margin: 60px auto 30px;
}
</style>
Loading

0 comments on commit 635a49e

Please sign in to comment.