Generates table of contents for markdown files inside local git repository. Link to file address.
Table of Contents generated with FileToc
- .vscode
- dist
- lib
- .editorconfig
- .gitignore
- .npmignore
- .prettierignore
- .prettierrc
- filetoc.config.js
- index.js
- package.json
- pnpm-lock.yaml
- README.md
- README.zh.md
- rollup.config.js
- tsconfig.json
npm install filetoc -g
// filetoc.config.js
module.exports = {
remoteUrl: 'https://github.com/chenfan0/dirtoc', // your repo address
mainBranch: 'main', // your default branch. default 'main'
dirPath: '.', // the dir where you want to gengerate the toc. default '.'
mdPath: ['./README.md', './README.zh.md'], // the markdown files path, when there is only one path, it also can be a string. default ['README.md']
excludes: ['.git'] // the excludes file name or dir name
}
You should specify where to insert the TOC in your markdown file.
<!--filetoc-start-->
toc will insert here
<!--filetoc-end-->
Go into the directory that contains you local git project and type:
filetoc
If you want to automatically modify the markdown for you before each commit.You can use husky to achieve this effect.
Go into the directory that contains you local git project and type:
npx husky-init && npm install
Find the pre-commit file under the generated husky folder and write in the file:
filetoc
git add .