Skip to content

Commit

Permalink
themes/mkdocs: Make base_url global (in the JS environment)
Browse files Browse the repository at this point in the history
This is to preserve compatibility with external scripts, like the search plugin.
  • Loading branch information
nbraud committed Nov 17, 2019
1 parent 4eb29c4 commit 4193834
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mkdocs/themes/mkdocs/js/base.js
Expand Up @@ -12,6 +12,12 @@ function getSearchTerm()
}
}

// Make base_url global, so external scripts can find it
// (e.g. the search plugin)
window.base_url = JSON.parse(document.querySelector(
`script[type="application/json"][mkdocs-selector="data"]`
).textContent).base_url;

$(document).ready(function() {
var {base_url, highlightjs, shortcuts} = JSON.parse(document.querySelector(
`script[type="application/json"][mkdocs-selector="data"]`
Expand Down

0 comments on commit 4193834

Please sign in to comment.