Skip to content

Commit 63fcb93

Browse files
committed
docs: support configure through frontmatter for Intro & Layout component
1 parent c4c74aa commit 63fcb93

File tree

2 files changed

+45
-19
lines changed

2 files changed

+45
-19
lines changed

docs/.vuepress/theme/components/Intro.vue

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,56 @@
11
<template>
22
<div class="intro-container">
3-
<p>An infinite scroll plugin for Vue.js</p>
3+
<p v-text="$description || 'Welcome to your VuePress site'"></p>
44
<router-link
55
class="button button-large button-basic"
6-
:to="'/guide/'"
6+
v-if="data.actionText && data.actionLink"
7+
:to="data.actionLink"
8+
v-text="data.actionText"
79
tag="button">
8-
Get Started
910
</router-link>
10-
<button class="button button-large">View GitHub</button>
11-
<ul class="feat-list">
12-
<li>
13-
<h3>Out of the box</h3>
14-
BalabalaBalabalaBalabalaBalabala
15-
</li>
16-
<li>
17-
<h3>2-direction support</h3>
18-
BalabalaBalabalaBalabalaBalabala
19-
</li>
20-
<li>
21-
<h3>Result display</h3>
22-
BalabalaBalabalaBalabalaBalabala
11+
<a :href="repoLink" class="button button-large"
12+
v-if="data.GitHubText && $themeConfig.repo"
13+
v-text="data.GitHubText">
14+
</a>
15+
<ul class="feat-list"
16+
v-if="data.features && data.features">
17+
<li v-for="(feature, index) in data.features">
18+
<h3 v-text="feature.title"></h3>
19+
{{ feature.details }}
2320
</li>
2421
</ul>
2522
</div>
2623
</template>
2724

25+
<script>
26+
export default {
27+
data() {
28+
return { data: {} };
29+
},
30+
watch: {
31+
'$page.frontmatter': {
32+
immediate: true,
33+
handler(val) {
34+
// only read home data
35+
if (val && val.home) {
36+
this.data = val;
37+
}
38+
},
39+
},
40+
},
41+
computed: {
42+
repoLink() {
43+
const link = this.$themeConfig.repo;
44+
45+
return /^https?:/.test(link)
46+
? link
47+
: `https://github.com/${link}`;
48+
},
49+
},
50+
};
51+
</script>
52+
53+
2854
<style lang="stylus" scoped>
2955
@require '../styles/config';
3056

docs/.vuepress/theme/layouts/Layout.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
<Previewer/>
6262
<Intro/>
6363

64-
<footer class="footer">
65-
<p>Released under the MIT License</p>
66-
<p>&copy;2016-present Made with ♥ under Vuepress by PeachScript</p>
64+
<footer class="footer"
65+
v-if="$themeConfig.footer || $themeLocaleConfig.footer"
66+
v-html="$themeConfig.footer || $themeLocaleConfig.footer">
6767
</footer>
6868
</div>
6969
</template>

0 commit comments

Comments
 (0)