Skip to content

Commit

Permalink
theme: fix showVisitedLinks in case Hugo is configured to modify rela…
Browse files Browse the repository at this point in the history
…tive URLs matcornic#86
  • Loading branch information
McShelby committed Sep 9, 2021
1 parent 5ef91db commit c5382e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion layouts/partials/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ <h3>{{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}</h3>
</li>
{{else}}
<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" . }}
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
</a>
Expand Down
7 changes: 6 additions & 1 deletion static/js/relearn.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,12 @@ jQuery(function() {

// loop through the sessionStorage and see if something should be marked as visited
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');
}
}
});

Expand Down

0 comments on commit c5382e0

Please sign in to comment.