gitbook build changes/updates the timestamp in all the html. How do I prevent it?
ithiru opened this issue · comments
I have been exploring using GitBook to publish a book and really thrilled building with it. I know delta build could be in the cards, in the meantime how do I prevent Gitbook adding timestamp to the HTMLs? That makes all the html has changed even though there is no content changes.
TIA.
We have the same problem, how can we avoid timestamp updates on files that didn't change?
+1
The timestamp is generated by code in ~/.gitbook/versions/3.2.3/lib/output/website/onPage.js
For windows : %USERPROFILE%\.gitbook\versions\3.2.3\lib\output\website\onPage.js
...
getJSContext: function() {
return {
page: omit(context.page, 'content'),
config: context.config,
file: context.file,
gitbook: context.gitbook, // change to Object.assign(context.file,{time:''})
basePath: basePath,
book: {
language: book.getLanguage()
}
};
}
...
Object.assign(context.file,{time:''})
will make time
a fixed value which in this example is an empty string.
painty's comment gave me a hint.
I could set timestamp blank.
Please modify gitbook's code as below.
~/.gitbook/versions/3.2.3/lib/json/encodeBook.js
...
return {
summary: encodeSummary(book.getSummary()),
glossary: encodeGlossary(book.getGlossary()),
readme: encodeReadme(book.getReadme()),
config: book.getConfig().getValues().toJS(),
languages: book.isMultilingual()? encodeLanguages(book.getLanguages()) : undefined,
gitbook: {
version: gitbook.version,
time: '' ### I changed this line. before -> //time: gitbook.START_TIME
},
book: extend({
language: language? language : undefined
}, variables.toJS())
};
...
warm regards