Skip to content

Commit

Permalink
Merge pull request #1261 from gethinode/develop
Browse files Browse the repository at this point in the history
Improve deployment to subfolder
  • Loading branch information
markdumay authored Oct 23, 2024
2 parents a730255 + f910d1b commit 1b96477
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
9 changes: 6 additions & 3 deletions assets/js/critical/languageSelector.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/* eslint-disable */
{{- if site.Params.main.enableLanguageSelectionStorage -}}
{{- if site.Params.main.enableLanguageSelectionStorage -}}
{{- $folder := (urls.Parse site.BaseURL).Path | default "/" -}}

(() => {
'use strict'

const folder = '{{ $folder }}'

// Function to get the selected language from local storage
function getLanguage () {
return getLocalStorage('selectedLanguage', document.documentElement.lang, 'functional')
Expand All @@ -22,7 +25,7 @@
window.location.href = href
}
} else {
window.location.href = '/' + language + '/'
window.location.href = folder + language + '/'
}
}
}
Expand Down Expand Up @@ -57,7 +60,7 @@
// Redirect to the localized homepage
const defaultLang = '{{ site.LanguageCode | default site.Language.Lang }}'
let language = storedLanguage ? storedLanguage : defaultLang
window.location.href = '/' + language + '/'
window.location.href = folder + language + '/'
}
})
})()
Expand Down
1 change: 0 additions & 1 deletion exampleSite/hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@
"body-file-collapse-1",
"bouton",
"breadcrumb",
"btn-webshare",
"button",
"button-group",
"card",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/gethinode/mod-leaflet v1.2.0 // indirect
github.com/gethinode/mod-lottie v1.5.11 // indirect
github.com/gethinode/mod-simple-datatables v1.0.14 // indirect
github.com/gethinode/mod-utils/v2 v2.8.2 // indirect
github.com/gethinode/mod-utils/v2 v2.8.3 // indirect
github.com/nextapps-de/flexsearch v0.0.0-20240501124520-961c3ae84a87 // indirect
github.com/twbs/bootstrap v5.3.3+incompatible // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ github.com/gethinode/mod-utils/v2 v2.8.1 h1:u7sFbgJ5sBEMYC/GwcMRyjRAd5NxTjBnbld5
github.com/gethinode/mod-utils/v2 v2.8.1/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.8.2 h1:rKndAMmRBSO5Cgoa/2CvF5XchDSvLvd4TYAbfbbQVhE=
github.com/gethinode/mod-utils/v2 v2.8.2/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/gethinode/mod-utils/v2 v2.8.3 h1:t1MJcIdFhYi0gCkm8f0DYZwyfq7pRdRc0eNpqZa11ic=
github.com/gethinode/mod-utils/v2 v2.8.3/go.mod h1:GTYeknoLujNjfDxI+V9Dcug26CYJSTJ0B/U2dagw9oY=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3 h1:H/qVR5O4BXjRjD+5PZB+r4ug2BSJ2Of4RtwOntd+OKo=
github.com/nextapps-de/flexsearch v0.0.0-20230711092928-1243fd883ec3/go.mod h1:5GdMfPAXzbA2gXBqTjC6l27kioSYzHlqDMh0+wyx7sU=
github.com/nextapps-de/flexsearch v0.0.0-20240108021025-afd75f742f22 h1:re7L8FxbXQpnX8BgzkdUnDpsUmloGNyLmiy2ZCln8pg=
Expand Down
10 changes: 9 additions & 1 deletion layouts/partials/assets/link.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
{{ end }}

<!-- Initialize arguments -->
{{ $destination := path.Clean (strings.TrimPrefix (strings.TrimSuffix "/" site.BaseURL) .destination) }}
{{ $destination := .destination }}
{{ $u := urls.Parse $destination }}
{{ if not $u.Scheme }}
{{ $b := urls.Parse site.BaseURL }}
{{ $destination = strings.TrimPrefix $b.Path $destination }}
{{ else }}
{{ $destination = (strings.TrimPrefix (strings.TrimSuffix "/" site.BaseURL) $destination) }}
{{ end }}
{{ $destination = path.Clean $destination }}
{{ if not $destination }}{{ $destination = "/" }}{{ end }}

{{- $target := "" -}}
Expand Down

0 comments on commit 1b96477

Please sign in to comment.