Created
April 17, 2018 16:44
-
-
Save jacoyutorius/91efd306e46007cb0d343293e379930c to your computer and use it in GitHub Desktop.
Vuepressで指定したディレクトリ配下に居るファイルをsidebarに定義する設定
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| const path = require('path'); | |
| // docs配下に属するディレクトリをサイドバーのグループに定義する | |
| // dir直下のディレクトリにしか対応していない | |
| var dirpath = "./docs" | |
| var dirs = fs.readdirSync(dirpath).filter((f) => { | |
| return fs.existsSync(dirpath + "/" + f) && fs.statSync(dirpath + "/" + f).isDirectory() | |
| }) | |
| var sidebarArray = ["/"].concat(dirs.map((dir) => { | |
| return { | |
| title: dir, | |
| collapsable: true, | |
| children: fs.readdirSync(dirpath + "/" + dir).map((childDir) => { | |
| return dirpath + "/" + dir + "/" + childDir | |
| }) | |
| } | |
| })) | |
| module.exports = { | |
| title: 'My Vuepress', | |
| description: 'Just playing around', | |
| config: (md) => { | |
| md.options.linkify = true | |
| }, | |
| themeConfig: { | |
| sidebar: sidebarArray | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment