Auto Set Categories

reco_luan2021-12-12 17:58:24

Introduction

In order to save users' time cost, the theme can automatically set the classification for the blog under the blogs folder, that is, set the name of the folder where the file is located to the value of the categories of the file's frontmatter.

/
└─ .vuepress
└─ blogs
  └─ Category 1
    └─ blog1.md
  └─ Category 2
    └─ blog2.md

Configure

WARNING

The autoAddCategoryToNavbar API will be adjusted later, but will not be abandoned, please use it with caution.

import { defineUserConfig } from 'vuepress'
import { recoTheme } from 'vuepress-theme-reco'

export default defineUserConfig({
  theme: recoTheme({
    // automatically set categories
    autoSetBlogCategories: true,
    // automatically add categories and tags to the header navigation bar
    autoAddCategoryToNavbar: {
      location: 1, // insertion position,default 0
      showIcon: true, // display icon,default false
    },
    // when autoAddCategoryToNavbar is true, all defaults are taken.
    autoAddCategoryToNavbar: true
  })
})
Last Updated 11/26/2024, 10:43:06 AM