mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(cli): support doc search
This commit is contained in:
parent
d9cedca9a8
commit
e461a80dbe
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app">
|
<div class="app">
|
||||||
<van-doc :config="config" :simulator="simulator">
|
<van-doc :lang="lang" :config="config" :simulator="simulator">
|
||||||
<router-view />
|
<router-view />
|
||||||
</van-doc>
|
</van-doc>
|
||||||
</div>
|
</div>
|
||||||
@ -32,6 +32,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
lang() {
|
||||||
|
const { lang } = this.$route.meta;
|
||||||
|
return lang || '';
|
||||||
|
},
|
||||||
|
|
||||||
config() {
|
config() {
|
||||||
const { locales } = config.site;
|
const { locales } = config.site;
|
||||||
|
|
||||||
|
@ -53,8 +53,7 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
lang: String,
|
lang: String,
|
||||||
config: Object,
|
config: Object,
|
||||||
versions: Array,
|
versions: Array
|
||||||
searchConfig: Object
|
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -67,6 +66,10 @@ export default {
|
|||||||
langLink() {
|
langLink() {
|
||||||
const { lang } = this.config.nav;
|
const { lang } = this.config.nav;
|
||||||
return `#${this.$route.path.replace(lang.from, lang.to)}`;
|
return `#${this.$route.path.replace(lang.from, lang.to)}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
searchConfig() {
|
||||||
|
return this.config.searchConfig;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<input class="van-doc-search" :placeholder="searchPlaceholder">
|
<input class="van-doc-search" :placeholder="placeholder">
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -12,8 +12,8 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
searchPlaceholder() {
|
placeholder() {
|
||||||
return this.lang === 'zh-CN' ? '搜索文档...' : 'Search...';
|
return this.searchConfig.placeholder || 'Search...';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
:lang="lang"
|
:lang="lang"
|
||||||
:config="config"
|
:config="config"
|
||||||
:versions="versions"
|
:versions="versions"
|
||||||
:search-config="searchConfig"
|
|
||||||
@switch-version="$emit('switch-version', $event)"
|
@switch-version="$emit('switch-version', $event)"
|
||||||
/>
|
/>
|
||||||
<doc-nav :base="base" :nav-config="config.nav" />
|
<doc-nav :base="base" :nav-config="config.nav" />
|
||||||
@ -44,7 +43,6 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
lang: String,
|
lang: String,
|
||||||
versions: Array,
|
versions: Array,
|
||||||
searchConfig: Object,
|
|
||||||
currentSimulator: Number,
|
currentSimulator: Number,
|
||||||
simulator: String,
|
simulator: String,
|
||||||
config: {
|
config: {
|
||||||
|
@ -8,8 +8,10 @@
|
|||||||
<meta http-Equiv="Cache-Control" Content="no-cache" />
|
<meta http-Equiv="Cache-Control" Content="no-cache" />
|
||||||
<meta http-Equiv="Pragma" Content="no-cache" />
|
<meta http-Equiv="Pragma" Content="no-cache" />
|
||||||
<meta http-Equiv="Expires" Content="0" />
|
<meta http-Equiv="Expires" Content="0" />
|
||||||
|
<link href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" rel="stylesheet" />
|
||||||
</head>
|
</head>
|
||||||
<body ontouchstart>
|
<body ontouchstart>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -22,6 +22,11 @@ module.exports = {
|
|||||||
url: 'https://github.com/youzan/vant'
|
url: 'https://github.com/youzan/vant'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
searchConfig: {
|
||||||
|
apiKey: '90067aecdaa2c85220e2783cd305caac',
|
||||||
|
indexName: 'vant',
|
||||||
|
placeholder: '搜索文档...'
|
||||||
|
},
|
||||||
nav: [
|
nav: [
|
||||||
{
|
{
|
||||||
title: '开发指南',
|
title: '开发指南',
|
||||||
@ -360,6 +365,11 @@ module.exports = {
|
|||||||
url: 'https://github.com/youzan/vant'
|
url: 'https://github.com/youzan/vant'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
searchConfig: {
|
||||||
|
apiKey: '90067aecdaa2c85220e2783cd305caac',
|
||||||
|
indexName: 'vant',
|
||||||
|
placeholder: 'Search...'
|
||||||
|
},
|
||||||
nav: [
|
nav: [
|
||||||
{
|
{
|
||||||
title: 'Essentials',
|
title: 'Essentials',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user