Skip to content

Commit

Permalink
local build: enable js-scripts loading locally; disable rewrite depen…
Browse files Browse the repository at this point in the history
…dent ones
  • Loading branch information
daringer committed Dec 14, 2024
1 parent 58d0682 commit 7b5476e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
19 changes: 12 additions & 7 deletions source/_static/js/toc-fixer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
document.addEventListener('DOMContentLoaded', function () {
// fix incorrect links in toc and language banners
document.querySelectorAll('a.internal, .related-pages a, #language-banner a').forEach(function(elem) {
elem.setAttribute('href', elem.href.replace('index.html', ''));
elem.setAttribute('href', elem.href.replace('.html', ''));
});

// fix incorrect links in toc and language banners
// (only works online with apach2 rewrite rules)
if (window.location.protocol != "file:") {
document.querySelectorAll('a.internal, .related-pages a, #language-banner a').forEach(function(elem) {
elem.setAttribute('href', elem.href.replace('index.html', ''));
elem.setAttribute('href', elem.href.replace('.html', ''));
});
}
// fix incorrect headline anchor links
document.querySelectorAll('a.toc-backref').forEach(function(elem) {
for (let sibling of elem.parentNode.children) {
Expand All @@ -20,5 +22,8 @@ document.addEventListener('DOMContentLoaded', function () {
}
});

document.querySelector('#breadcrumbs a.current').remove();
elem = document.querySelector('#breadcrumbs a.current');
if (elem)
elem.remove();

}, false);
7 changes: 4 additions & 3 deletions source/_templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@

</div>
</div>
<script src="/_static/js/theme-switcher.js"></script>
<script src="/_static/js/toc-fixer.js"></script>
<script src="/_static/js/quick-links.js"></script>
{% set base_path = "/".join(pathto('index').split("/")[:-1]) %}
{% set path_prefix = base_path + "/" if base_path else "" %}
<script src="{{ path_prefix }}_static/js/theme-switcher.js"></script>
<script src="{{ path_prefix }}_static/js/toc-fixer.js"></script>
{%- endblock %}

0 comments on commit 7b5476e

Please sign in to comment.