Skip to content

Instantly share code, notes, and snippets.

@jacoyutorius
Created April 17, 2018 16:44
Show Gist options
  • Select an option

  • Save jacoyutorius/91efd306e46007cb0d343293e379930c to your computer and use it in GitHub Desktop.

Select an option

Save jacoyutorius/91efd306e46007cb0d343293e379930c to your computer and use it in GitHub Desktop.
Vuepressで指定したディレクトリ配下に居るファイルをsidebarに定義する設定
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