mirror of https://github.com/onweru/compose.git

Robert Mihaly
07.44.2022 5b724e6023770d24323df1b5ae68119b4f9347f2
Set rootURL to the site's baseURL

This fixes loading images and other assets in javascripts, when the site
is not deployed to the root folder, but into a sub-folder.

The fix replaces the server host based `rootURL` with Hugo's `baseURL`.
Since this URL is used in calls to `new URL`, it needs to end with a
trailing slash for the URLs to be constructed correctly.
1 files modified
3 ■■■■ changed files
assets/js/variables.js 3 ●●●● patch | view | raw | blame | history
assets/js/variables.js
@@ -4,7 +4,8 @@
const showId = 'show';
const menu = 'menu';
const active = 'active';
const rootURL = window.location.protocol + "//" + window.location.host;
// rootURL must end with '/' for relative URLs to work properly
const rootURL = '{{ strings.TrimSuffix "/" .Site.BaseURL }}/';
const searchFieldClass = '.search_field';
const searchClass = '.search';
const goBackClass = 'button_back';