forked from ktquez/vuepress-theme-ktquez
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenhanceApp.js
28 lines (22 loc) · 889 Bytes
/
enhanceApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { filterPages, sortArrayByProp } from '@theme/services/utils'
import { post as PostTransformer } from '@theme/transformers/post'
import Translation from '@theme/plugins/Translation'
export default ({ Vue, siteData }) => {
Vue.prototype.$themeConfig = siteData.themeConfig
Vue.prototype.$posts = getPosts(siteData.pages)
Vue.prototype.$categories = getCategories(siteData.pages)
Vue.prototype.$authors = getAuthors(siteData.pages)
Vue.use(Translation)
// Global components to use in markdown
Vue.component('lazy-load', () => import('@theme/components/lazy/load'))
}
function getPosts (pages) {
const posts = filterPages(pages, 'post', true)
return sortArrayByProp(PostTransformer(posts), 'created_time', 'desc')
}
function getAuthors (pages) {
return filterPages(pages, 'author')
}
function getCategories (pages) {
return filterPages(pages, 'category')
}