|
1 | 1 | <template> |
2 | 2 | <div class="home-blog" :class="recoShow?'reco-show': 'reco-hide'"> |
3 | 3 | <div class="hero" :style="{background: `url(${$frontmatter.bgImage ? $withBase($frontmatter.bgImage) : require('../images/home-bg.jpg')}) center/cover no-repeat`, ...bgImageStyle}"> |
4 | | - <h1>{{ data.heroText || $title || '午后南杂' }}</h1> |
| 4 | + <h1>{{ homeFrontmatter.heroText || $title || '午后南杂' }}</h1> |
5 | 5 |
|
6 | | - <p class="description">{{ data.tagline || $description || 'Welcome to your vuePress-theme-reco site' }}</p> |
| 6 | + <p class="description">{{ $description || 'Welcome to your vuePress-theme-reco site' }}</p> |
7 | 7 | <p class="huawei" v-if="$themeConfig.huawei === true"><i class="iconfont reco-huawei" style="color: #fc2d38"></i> 华为,为中华而为之!</p> |
8 | 8 | </div> |
9 | 9 |
|
@@ -72,47 +72,54 @@ export default { |
72 | 72 | computed: { |
73 | 73 | // 时间降序后的博客列表 |
74 | 74 | posts () { |
75 | | - let posts = this.$site.pages |
76 | | - posts = this._filterPostData(posts) |
77 | | - this._sortPostData(posts) |
| 75 | + const { |
| 76 | + $site: { pages }, |
| 77 | + _filterPostData, |
| 78 | + _sortPostData |
| 79 | + } = this |
| 80 | +
|
| 81 | + let posts = pages |
| 82 | + posts = _filterPostData(posts) |
| 83 | + _sortPostData(posts) |
| 84 | +
|
78 | 85 | return posts |
79 | 86 | }, |
80 | | -
|
81 | 87 | // 分类信息 |
82 | 88 | getPagesLength () { |
83 | | - let num = 0 |
84 | | - this.$categories.list.map(v => { |
85 | | - num += v.pages.length |
86 | | - }) |
87 | | - return num |
| 89 | + return this.posts.length |
88 | 90 | }, |
89 | | - data () { |
| 91 | + homeFrontmatter () { |
90 | 92 | return this.$frontmatter |
91 | 93 | }, |
92 | | -
|
93 | 94 | actionLink () { |
| 95 | + const { |
| 96 | + actionLink: link, |
| 97 | + actionText: text |
| 98 | + } = this.homeFrontmatter |
| 99 | +
|
94 | 100 | return { |
95 | | - link: this.data.actionLink, |
96 | | - text: this.data.actionText |
| 101 | + link, |
| 102 | + text |
97 | 103 | } |
98 | 104 | }, |
99 | | -
|
100 | 105 | heroImageStyle () { |
101 | | - return this.data.heroImageStyle || { |
| 106 | + return this.homeFrontmatter.heroImageStyle || { |
102 | 107 | maxHeight: '200px', |
103 | 108 | margin: '6rem auto 1.5rem' |
104 | 109 | } |
105 | 110 | }, |
106 | | -
|
107 | 111 | bgImageStyle () { |
108 | | - const bgImageStyle = { |
| 112 | + const initBgImageStyle = { |
109 | 113 | height: '350px', |
110 | 114 | textAlign: 'center', |
111 | 115 | overflow: 'hidden' |
112 | 116 | } |
113 | | - return this.data.bgImageStyle ? { ...bgImageStyle, ...this.data.bgImageStyle } : bgImageStyle |
114 | | - }, |
| 117 | + const { |
| 118 | + bgImageStyle |
| 119 | + } = this.homeFrontmatter |
115 | 120 |
|
| 121 | + return bgImageStyle ? { ...initBgImageStyle, ...bgImageStyle } : initBgImageStyle |
| 122 | + }, |
116 | 123 | heroHeight () { |
117 | 124 | return document.querySelector('.hero').clientHeight |
118 | 125 | } |
@@ -142,10 +149,6 @@ export default { |
142 | 149 | const base = this.$site.base |
143 | 150 | window.location.href = `${base}tag/?tag=${currentTag}` |
144 | 151 | }, |
145 | | - // 获取时间的数字类型 |
146 | | - _getTimeNum (data) { |
147 | | - return parseInt(new Date(data.frontmatter.date).getTime()) |
148 | | - }, |
149 | 152 | _setPage (page) { |
150 | 153 | this.currentPage = page |
151 | 154 | this.$page.currentPage = page |
|
0 commit comments