GitbookIO / gitbook-cli

GitBook's command line interface
716 stars 216 forks source link

gitbook build changes/updates the timestamp in all the html. How do I prevent it? #48

Open ithiru opened 8 years ago

ithiru commented 8 years ago

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.

bettiolo commented 7 years ago

We have the same problem, how can we avoid timestamp updates on files that didn't change?

zh79325 commented 6 years ago

+1

painty commented 6 years ago

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.

agrexgh commented 4 years ago

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