show git author for each article of gitbook
npm install gitbook-plugin-git-authorThis is a plugin for automatically adding author and timestamp to each gitbook article, including creator and last modified user from git commits
- Node.js 4.0+
- npm 3.0+
- gitbook 3.0+
``sh`
npm i -D gitbook-plugin-git-author
`js`
{
"plugins": ["git-author"]
"pluginsConfig": {
"git-author":{
"position": "bottom",
"modifyTpl": "Last modified by {user} {timeStamp}",
"createTpl": "Created by {user} {timeStamp}",
"timeStampFormat": "YYYY-MM-DD HH:mm:ss"
}
}
}
README.md file
Be sure to commit this file to git repository firstly.
`markdownTitle of the Article
content
`
`htmlTitle of the Article
content
Options
$3
default:
bottomgit-author content position in the article.
top or bottom this will add a
git-author-{position} className to git-author-container$3
You can use
{user} {timeStamp} as placeholder for username and timeStampdefault:
createTpl:
Created by {user} {timeStamp}modifyTpl:
Last modified by {user} {timeStamp}You may disable one of them by set it to a FALSY value.
e.g
`
"createTpl": false
`$3
default:
YYYY-MM-DD HH:mm:ssuse moment to process timeStamp
Useful filters
You can use
timeFormat nunjucks filter to format time string in each article.$3
`
{{ 1466749374153 | timeFormat('YYYY-MM-DD') }}
`output
`
2016-06-24
``
{{ '2016-06-24T07:27:04.365Z' | timeFormat('MMMM Do YYYY, h:mm:ss a') }}
`output
`
June 24th 2016, 3:27:04 pm
`Custom styles
change default style by add a custom css file to your gitbook
book.json`js
{
"styles": {
"website": "./styles/website.css"
}
}
`website.css`
.git-author-container {
font-size: 85%;
}.git-author-top {
float: none;
}
``