theme: attempt to remove relative URL hack #804

This commit is contained in:
Sören Weber 2024-03-16 14:43:57 +01:00
parent 17b38325c4
commit b178d3ea99
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -28,12 +28,9 @@
<link href="{{"css/ie.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
<script src="{{"js/url.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script id="R-inline-script" data-root-url="/">
{{ "// hack to let hugo tell us how to get to the root when using relativeURLs, it needs to be called *url= for it to do its magic:" | safeJS }}
{{ "// https://github.com/gohugoio/hugo/blob/145b3fcce35fbac25c7033c91c1b7ae6d1179da8/transform/urlreplacers/absurlreplacer.go#L72" | safeJS }}
var root_url=document.querySelector( '#R-inline-script' ).dataset.rootUrl;
<script>
window.relearn = window.relearn || {};
window.relearn.baseUri=root_url.replace(/\/*$/, '');
window.relearn.baseUri='{{ "css/theme.css" | relURL | safeJS }}'.replace(/(.*)css\/theme\.css/, '$1').replace(/\/*$/, '');
window.relearn.baseUriFull='{{ .Site.BaseURL | safeJS }}/'.replace(/\/*$/, '');
{{- with .Site.Home.OutputFormats.Get "json" }}
{{- warnf "%q: DEPRECATED usage of 'json' output format found, use 'search' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/customization#activate-search" $page.File.Filename }}