0.1.0 • Published 2 years ago

vuepress-plugin-posts v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vuepress-plugin-posts

Version Downloads

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 language

  • usePost - Get data for current, previous and next post

Post has the following data:

  • availableLanguages - Links to this post in other languages
  • formattedDate - Post date
  • date - Unformatted date
  • language - Post language
  • path - Link to post URL
  • readingTime - Reading time for post in minutes
  • title - 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.