mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Provide gitbook.state.root to plugins
This commit is contained in:
@@ -1,14 +1,19 @@
|
||||
var $ = require('jquery');
|
||||
var url = require('url');
|
||||
var path = require('path');
|
||||
|
||||
var state = {};
|
||||
|
||||
state.update = function(dom) {
|
||||
var $book = $(dom.find(".book"));
|
||||
var $book = $(dom.find('.book'));
|
||||
|
||||
state.$book = $book;
|
||||
state.level = $book.data("level");
|
||||
state.basePath = $book.data("basepath");
|
||||
state.revision = $book.data("revision");
|
||||
state.level = $book.data('level');
|
||||
state.basePath = $book.data('basepath');
|
||||
state.revision = $book.data('revision');
|
||||
|
||||
// Absolute url to the root of the book
|
||||
state.root = url.resolve(location.origin, path.dirname(path.resolve(location.pathname, state.basePath)));
|
||||
};
|
||||
|
||||
state.update($);
|
||||
|
||||
Reference in New Issue
Block a user