Skip to content

Commit

Permalink
fix: hide tag icon when untagged for search
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticLampyrid committed Jun 3, 2024
1 parent 26137b9 commit f2de8cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion layout/_pages/search.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@
<div class="kratos-entry-post-meta">
<span class="pull-left">
<a><i class="fa fa-calendar"></i></a><a>$DATE</a>
<a><i class="fa fa-tags"></i></a>
$TAGS
</span>
</div>
</div>
</article>
</template>

<template id="kr-search-tag-begin-template">
<a><i class="fa fa-tags"></i></a>
</template>

<template id="kr-search-tag-template">
<a class="tag-link" href="$LINK" rel="tag">$TAG</a>
</template>
Expand Down
10 changes: 9 additions & 1 deletion src/js/kr-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
const resultTemplate = document.getElementById(
"kr-search-result-template",
).innerHTML;
const resultTagBeginTemplate = document.getElementById(
"kr-search-tag-begin-template",
).innerHTML;
const resultTagTemplate = document.getElementById(
"kr-search-tag-template",
).innerHTML;
Expand Down Expand Up @@ -86,7 +89,12 @@
.replaceAll("$TITLE", resultInfo.title)
.replaceAll("$CONTENT", resultInfo.content)
.replaceAll("$DATE", resultInfo.date)
.replaceAll("$TAGS", resultTags.join(", "));
.replaceAll(
"$TAGS",
resultTags.length !== 0
? resultTagBeginTemplate + resultTags.join(", ")
: "",
);
}
document.getElementById("kr-search-results").innerHTML = resultString;
};
Expand Down

0 comments on commit f2de8cc

Please sign in to comment.