0.1.0 • Published 2 years ago
vuepress-plugin-posts v0.1.0
vuepress-plugin-posts
VuePress v2 plugin for blogging.
Installation
npm install --save vuepress-plugin-posts
Usage
Add plugin to your VuePress config:
import { postsPlugin } from 'vuepress-plugin-posts'
export default {
plugins: [postsPlugin()],
}
Add frontmatter markup to your blog posts:
---
title: My awesome article
date: 2022-02-16
---
Use hooks in your components:
usePosts
- To get post list for current languageusePost
- Get data for current, previous and next post
Post has the following data:
availableLanguages
- Links to this post in other languagesformattedDate
- Post datedate
- Unformatted datelanguage
- Post languagepath
- Link to post URLreadingTime
- Reading time for post in minutestitle
- Post title
Example
<script setup>
import { usePosts } from 'vuepress-plugin-posts/client'
let posts = usePosts()
</script>
<template>
<div v-for="{ title, path, formattedDate } in posts" :key="title">
<RouterLink :to="path">
<h3 v-text="title" />
</RouterLink>
<span v-text="formattedDate" />
</div>
</template>
Contribution
See Contribution guide.
0.1.0
2 years ago