Files
gitbook/theme/javascript/state.js
T
2015-10-22 16:12:21 +02:00

30 lines
668 B
JavaScript

var $ = require('jquery');
var url = require('url');
var path = require('path');
var state = {};
state.update = function(dom) {
var $book = $(dom.find('.book'));
state.$book = $book;
state.level = $book.data('level');
state.basePath = $book.data('basepath');
// Date of build
state.revision = $book.data('revision');
// Original path of the file
state.filepath = $book.data('filepath');
// Absolute url to the root of the book
state.root = url.resolve(
location.protocol+'//'+location.host,
path.dirname(path.resolve(location.pathname, state.basePath))
);
};
state.update($);
module.exports = state;