Skip to content

ryo-gk/vitepress-blog-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vitepress-blog-util

This is a utility for creating blogs by vitepress.

Functions

getPostList(path)

This can be used in docs/.vitepress/config.js like below.

You can pass the directory which includes the blog posts written in markdown format.

- Example

const { getPostList } = require('vitepress-blog-util/scripts')

module.exports = {
  base: '/',
  title: 'Title',
  description: 'Vitepress blog',
  themeConfig: {
    postList: getPostList('./docs/posts'),
  },
}

- Directory

|- docs
 |- .vitepress
 |- posts
  |- sample1.md
  |- sample2.md
 |- index.md
|- package.json
|...

usePostList()

This can be used to get the list of blog posts. Post has the below.

  • path : The path of the post's file.
  • content : The content of the post.
  • frontmatter : The frontmatter of the post.

filterPostList(postList, callback)

This can be used to filter post lists by the frontmatter.

You need to pass the post list to the 1st arg, and pass a callback function to the 2nd arg. The callback should accept the frontmatter object as arg, and return boolean.

- Example

const filteredPostList = filterPostList(postList, (fm) => {
  return fm.tags.includes('vitepress')
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published