Created
June 18, 2018 11:21
-
-
Save MartinMuzatko/ffab3d9d464c152349f493ea881a2942 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ({ | |
Vue, // the version of Vue being used in the VuePress app | |
options, // the options for the root Vue instance | |
router, // the router instance for the app | |
siteData // site metadata | |
}) => { | |
Vue.prototype.$getPosts = (maxPosts = 10) => { | |
let posts = siteData.pages | |
.filter(page => | |
page.frontmatter.layout == 'Post' && | |
page.path.startsWith('/articles/') && | |
!page.frontmatter.hidden | |
) | |
.sort((a,b) => new Date(a.frontmatter.published) - new Date(b.frontmatter.published)) | |
.reverse() | |
if (maxPosts == -1) return posts | |
return posts.slice(0, maxPosts) | |
} | |
Vue.mixin({ | |
computed: { | |
$title() { | |
return `${this.$page.title} | ${this.$siteTitle}` | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thank you for the information.
I would like to know the basics and power of enhanceApp.js in VuePress.
I would like to add Vue components inside my VuePress pages besides my static content.
My work: https://hemasthoughts.com/dynamic/
It would be great if you share more about enhanceApp.js OR some good links to learn.
Thanks a lot in advance.