Code Monkey home page Code Monkey logo

vitepress-sidebar-builder's Introduction

Vitepress Sidebar Builder

A very simple sidebar builder that lets the end user specify which folders to pull data from, and automatically constructs and orders pages based on front-matter (grey-matter) inside of the page itself.

Features

  • Can read all markdown files in a folder.
    • Does not recurse.
  • Can read all markdown files from a folder.
    • Recurses and finds all files from all folders.
  • Orders files by an order front-matter property.
  • Automatically uses title from front-matter property for sidebar title.
  • Ability to ignore specific files from being captured.

Installation

npm install @stuyk/vitepress-sidebar-builder

Usage

Setting Up Markdown Pages

!!! THIS IS REALLY IMPORTANT

All of your pages need to include some front-matter data.

Append this to the top of your markdown page.

---
title: 'My Fancy Title'
order: 0
---

# {{ $frontmatter.title }}

Constructing the Sidebar

Inside of docs/.vitepress/theme/config.js.

Here is an example of retrieving different sections of your documentation.

You will need to append different sections to themeConfig.sidebar object.

import SidebarBuilder from "@stuyk/vitepress-sidebar-builder";

export default {
    ... // Rest of the Config Above
    themeConfig: {
        sidebar: {
            '/section-name/': [
                {
                    text: 'Introduction',
                    collapsible: true,
                    // Retrieves all markdown files, 
                    // but does not retrieve any other files in this folder.
                    // Ignores any files with '_partial' in their name.
                    items: SidebarBuilder.get.filesAndOrder('./docs/section-name', ['_partial'])
                },
            ],
            '/lots-of-files/': [
                // Obtains 1 Folder of Files
                {
                    text: 'Just the Files',
                    collapsible: true,
                    items: SidebarBuilder.get.filesAndOrder('./docs/lots-of-files', ['_partial'])
                },
                // Obtains Many Folders & All files
                ...SidebarBuilder.get.foldersAndOrder('./docs/lots-of-files', {
                        collapsed: false,
                        collapsible: true,
                        partialFileNamesToIgnore: ['_partial'],
                    }
                )
            ]
        }
    }
    ... // Rest of the Config Above
}

vitepress-sidebar-builder's People

Contributors

stuyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.