Skip to content

Commit

Permalink
theme/base.js: Avoid modern JS constructs for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
nbraud committed Nov 17, 2019
1 parent 0d6e494 commit 1eb59ea
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions theme/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ 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"]`
'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"]`
var data = JSON.parse(document.querySelector(
'script[type="application/json"][mkdocs-selector="data"]'
).textContent);
var search_term = getSearchTerm(),
shortcuts = data.shortcuts,
$search_modal = $('#mkdocs_search_modal'),
$keyboard_modal = $('#mkdocs_keyboard_modal');

if(highlightjs) {
if(data.highlightjs) {
hljs.initHighlightingOnLoad();
}

Expand Down

1 comment on commit 1eb59ea

@reuvenpo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to set it up myself, or if it's even possible when using mkdocs, but using something like webpack you can even use unstable syntax and features, and just transpile them to be compatible with browsers from whenever you want

Please sign in to comment.