Skip to content

Instantly share code, notes, and snippets.

@MartinMuzatko
Created June 18, 2018 11:21
Show Gist options
  • Save MartinMuzatko/ffab3d9d464c152349f493ea881a2942 to your computer and use it in GitHub Desktop.
Save MartinMuzatko/ffab3d9d464c152349f493ea881a2942 to your computer and use it in GitHub Desktop.
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}`
}
}
})
}
@pmarimuthu
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment