From 51eb84391b55c123cc64b3812b620e53fa6d4bbb Mon Sep 17 00:00:00 2001 From: rainbowpigeon <16717153+rainbowpigeon@users.noreply.github.com> Date: Mon, 3 May 2021 17:29:31 +0800 Subject: Fix 'undefined' href in search results without highlight If enableSearchHighlight = false is set in params.toml, populated search results will use the makeLi function to set href to obj.item.permalink as opposed to obj.item.uri when the makeHighlightLi function is used. obj.item.permalink used will result in undefined attribute and invalid links. --- layouts/partials/head/scripts.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/head/scripts.html b/layouts/partials/head/scripts.html index 3f0ba08..dba8cde 100644 --- a/layouts/partials/head/scripts.html +++ b/layouts/partials/head/scripts.html @@ -722,7 +722,7 @@ var a = document.createElement('a'); a.innerHTML = obj.item.title; a.setAttribute('class', 'search-result__item--title'); - a.setAttribute('href', obj.item.permalink); + a.setAttribute('href', obj.item.uri); var descDiv = document.createElement('div'); descDiv.setAttribute('class', 'search-result__item--desc'); @@ -1322,4 +1322,4 @@ } // ============================================================ }); - \ No newline at end of file + -- cgit v1.2.3