Fix pinned post URL on single-user instances

Previously, the URL of the dynamically-added pinned post on a
single-user instance would include the username, causing the link to go
to a non-existent page. This fixes that.
This commit is contained in:
Matt Baer 2019-08-07 15:47:49 -04:00
parent a48b746706
commit f6dc07850b
2 changed files with 2 additions and 2 deletions

View File

@ -141,7 +141,7 @@ function pinPost(e, postID, slug, title) {
var $header = document.getElementsByTagName('header')[0]; var $header = document.getElementsByTagName('header')[0];
var $pinnedNavs = $header.getElementsByTagName('nav'); var $pinnedNavs = $header.getElementsByTagName('nav');
// Add link to nav // Add link to nav
var link = '<a class="pinned" href="/{{.Alias}}/'+slug+'">'+title+'</a>'; var link = '<a class="pinned" href="{{if not .SingleUser}}/{{.Alias}}/{{end}}'+slug+'">'+title+'</a>';
if ($pinnedNavs.length == 0) { if ($pinnedNavs.length == 0) {
$header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>'); $header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>');
} else { } else {

View File

@ -176,7 +176,7 @@ function pinPost(e, postID, slug, title) {
var $header = document.getElementsByTagName('header')[0]; var $header = document.getElementsByTagName('header')[0];
var $pinnedNavs = $header.getElementsByTagName('nav'); var $pinnedNavs = $header.getElementsByTagName('nav');
// Add link to nav // Add link to nav
var link = '<a class="pinned" href="/{{.Alias}}/'+slug+'">'+title+'</a>'; var link = '<a class="pinned" href="{{if not .SingleUser}}/{{.Alias}}/{{end}}'+slug+'">'+title+'</a>';
if ($pinnedNavs.length == 0) { if ($pinnedNavs.length == 0) {
$header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>'); $header.insertAdjacentHTML("beforeend", '<nav>'+link+'</nav>');
} else { } else {