dynamic load of javascript files now knows its relative path...

This commit is contained in:
Marcell Mars 2020-09-12 17:17:36 +02:00
parent 6bb117b2f5
commit f864c9764f
2 changed files with 7 additions and 2 deletions

View File

@ -53,11 +53,14 @@ window.addEventListener('DOMContentLoaded', (e) => {
document.querySelector("#TableOfContents > ol:first-child").insertBefore(s, document.querySelector("#TableOfContents > ol:first-child").firstChild)
if (document.querySelector(".soundcite")) {
let relPath ="../".repeat(relPathDepth - 1);
var popcorn = document.createElement('script');
popcorn.src = `/js/popcorn.min.js`;
popcorn.src = `${relPath}js/popcorn.min.js`;
document.body.appendChild(popcorn);
var soundcite = document.createElement('script');
soundcite.src = `/js/soundcite.min.js`;
soundcite.src = `${relPath}js/soundcite.min.js`;
document.body.appendChild(soundcite);
}

View File

@ -25,6 +25,8 @@
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#996561">
<script type="text/javascript">var relPathDepth = {{ .RelPermalink | strings.Count "/" }};</script>
{{ $sjsopts := dict "targetPath" "js/sandpoints.js" "minify" "true"}}
{{ $sjs := resources.Get "js/sandpoints.js" | js.Build $sjsopts }}
<script defer src='{{ $sjs.Permalink }}' type="application/javascript"></script>