Removed the "<base>" element
This was breaking links, especially images and '#elem_id' fragment URLs.
This commit is contained in:
parent
b0101a0a1a
commit
f2ae6de673
@ -5,13 +5,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width">
|
<meta name="viewport" content="width=device-width">
|
||||||
<base href="{{ .Site.BaseURL }}"/>
|
|
||||||
{{ .Hugo.Generator }}{{/* See: https://gohugo.io/themes/creating/#theme-description-file */}}
|
{{ .Hugo.Generator }}{{/* See: https://gohugo.io/themes/creating/#theme-description-file */}}
|
||||||
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
|
<title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
|
||||||
<link rel="stylesheet" href="css/styles.css">
|
<link rel="stylesheet" href="{{ "css/styles.css" | relURL }}">
|
||||||
<link id="theme_css" rel="stylesheet" href="css/themes/{{ .Site.Params.ThemeStyle | default $themeStyleDefault }}">
|
<link id="theme_css" rel="stylesheet" href="{{ "css/themes" | relURL }}/{{ .Site.Params.ThemeStyle | default $themeStyleDefault }}">
|
||||||
{{- if .Site.Params.ThemeStyleSwitcher }}
|
{{- if .Site.Params.ThemeStyleSwitcher }}
|
||||||
<script src="js/theme-switcher.js"></script>
|
<script src="{{ "js/theme-switcher.js" | relURL }}"></script>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -30,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<label id="show-hide-menu-label" class="clickable-header-label" for="toggle-1">
|
<label id="show-hide-menu-label" class="clickable-header-label" for="toggle-1">
|
||||||
<img class="color-adapting-image" width="30" src="images/hamburger.svg" alt="menu button">
|
<img class="color-adapting-image" width="30" src="{{ "images/hamburger.svg" | relURL }}" alt="menu button">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<label class="overlay" for="toggle-1"></label>
|
<label class="overlay" for="toggle-1"></label>
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
// in Firefox we need to add a new css style with document.write rather than modifying the href
|
// in Firefox we need to add a new css style with document.write rather than modifying the href
|
||||||
// of the existing one, otherwise the screen will flash white while loading on dark themes
|
// of the existing one, otherwise the screen will flash white while loading on dark themes
|
||||||
var theme_css_elem = document.getElementById('theme_css');
|
var theme_css_elem = document.getElementById('theme_css');
|
||||||
|
var js_url = document.currentScript.src; // example: http://example.com/myhugo/js/theme-switcher.js
|
||||||
if(localStorage.getItem('theme') === 'dark'){
|
if(localStorage.getItem('theme') === 'dark'){
|
||||||
var clone = theme_css_elem.cloneNode(false);
|
var clone = theme_css_elem.cloneNode(false);
|
||||||
clone.href = "css/themes/dark.css";
|
clone.href = new URL("../css/themes/dark.css", js_url);
|
||||||
theme_css_elem.remove();
|
theme_css_elem.remove();
|
||||||
document.write(clone.outerHTML);
|
document.write(clone.outerHTML);
|
||||||
}else if(localStorage.getItem('theme') === 'light'){
|
}else if(localStorage.getItem('theme') === 'light'){
|
||||||
var clone = theme_css_elem.cloneNode(false);
|
var clone = theme_css_elem.cloneNode(false);
|
||||||
clone.href = "css/themes/light.css";
|
clone.href = new URL("../css/themes/light.css", js_url);
|
||||||
theme_css_elem.remove();
|
theme_css_elem.remove();
|
||||||
document.write(clone.outerHTML);
|
document.write(clone.outerHTML);
|
||||||
}
|
}
|
||||||
@ -20,19 +21,19 @@ function update_toggle_button(){
|
|||||||
var button = document.getElementById('change-theme-button');
|
var button = document.getElementById('change-theme-button');
|
||||||
button.style.display = "";
|
button.style.display = "";
|
||||||
if(elem.href.endsWith('light.css')){
|
if(elem.href.endsWith('light.css')){
|
||||||
button.getElementsByTagName('img')[0].src = 'images/theme-switcher-moon.svg';
|
button.getElementsByTagName('img')[0].src = new URL('../images/theme-switcher-moon.svg', js_url);
|
||||||
}else if(elem.href.endsWith('dark.css')){
|
}else if(elem.href.endsWith('dark.css')){
|
||||||
button.getElementsByTagName('img')[0].src = 'images/theme-switcher-sun.svg';
|
button.getElementsByTagName('img')[0].src = new URL('../images/theme-switcher-sun.svg', js_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle_theme(){
|
function toggle_theme(){
|
||||||
var elem = document.getElementById('theme_css');
|
var elem = document.getElementById('theme_css');
|
||||||
if(elem.href.endsWith('light.css')){
|
if(elem.href.endsWith('light.css')){
|
||||||
elem.href = "css/themes/dark.css";
|
elem.href = new URL("../css/themes/dark.css", js_url);
|
||||||
localStorage.setItem('theme', 'dark');
|
localStorage.setItem('theme', 'dark');
|
||||||
}else if(elem.href.endsWith('dark.css')){
|
}else if(elem.href.endsWith('dark.css')){
|
||||||
elem.href = "css/themes/light.css";
|
elem.href = new URL("../css/themes/light.css", js_url);
|
||||||
localStorage.setItem('theme', 'light');
|
localStorage.setItem('theme', 'light');
|
||||||
}
|
}
|
||||||
update_toggle_button();
|
update_toggle_button();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user