mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
theme: fix showVisitedLinks in case Hugo is configured to modify relative URLs #86
This commit is contained in:
parent
5ef91dbbce
commit
c5382e0bcc
2 changed files with 7 additions and 2 deletions
|
@ -135,7 +135,7 @@
|
||||||
</li>
|
</li>
|
||||||
{{else}}
|
{{else}}
|
||||||
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}">
|
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}">
|
||||||
<a href="{{ .RelPermalink}}">
|
<a href="{{.RelPermalink}}">
|
||||||
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
|
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
|
||||||
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
|
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -527,7 +527,12 @@ jQuery(function() {
|
||||||
|
|
||||||
// loop through the sessionStorage and see if something should be marked as visited
|
// loop through the sessionStorage and see if something should be marked as visited
|
||||||
for (var url in sessionStorage) {
|
for (var url in sessionStorage) {
|
||||||
if (sessionStorage.getItem(url) == 1) jQuery('[data-nav-id="' + url + '"]').addClass('visited');
|
if (sessionStorage.getItem(url) == 1){
|
||||||
|
// in case we have `relativeURLs=true` we have to strip the
|
||||||
|
// relative path to root
|
||||||
|
url = url.replace( /\.\.\//g, '/' ).replace( /^\/+\//, '/' );
|
||||||
|
jQuery('[data-nav-id="' + url + '"]').addClass('visited');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue