文档改为 Route.vue 组件

This commit is contained in:
Henry 2018-09-15 16:38:11 +01:00
parent 29ffa930e5
commit dc02466edf
2 changed files with 384 additions and 1817 deletions

View File

@ -0,0 +1,66 @@
<template>
<div class="routeBlock" :id="path">
<h4 :id=path class="name">{{name}} <Author :uid=author />
<a :href="'#'+path" aria-hidden="true" class="header-anchor">#</a>
</h4>
<p class="example">
举例: <a :href="'https://rsshub.app'+ example " target="_blank">https://rsshub.app{{example}}</a>
</p>
<p class="path">
路由: <code>{{ path }}</code>
</p>
<div v-if="path.match(/(?<=:).*?(?=\/|$)/g)">
<p>
参数:
<ul><li class="params" v-for="(item, index) in path.match(/(?<=:).*?(?=\/|$)/g)">{{item.replace('?','')}}, {{(item.includes('?'))?'可选':'必选'}} - <span v-html="renderMarkdown(paramsDesc[index])"></span></li></ul> </p>
</div>
<div v-else><p>参数: </p></div>
<slot></slot>
</div>
</template>
<script>
import Author from "./Author.vue"
export default {
components:{
'Author': Author
},
props: {
author: {
type: String,
default: 'DIYgod'
},
name: {
type: String,
required: true
},
path: {
type: String,
required: true
},
example: {
type: String,
required: true
},
paramsDesc: {
type: [Array, String],
default: '无'
}
},
methods: {
renderMarkdown(item) {
const md = require('markdown-it')({
html: true,
});
return md.render(item);
},
}
}
</script>
<style>
li.params p {
display: inline;
}
.routeBlock {
margin: 1rem 0 2rem;
}
</style>

File diff suppressed because it is too large Load Diff