From 93e0487703fdaa9e405b657208a58c91379281ca Mon Sep 17 00:00:00 2001 From: Meekdai Date: Tue, 21 Nov 2023 18:17:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B6=E9=83=A8=E6=B7=BB=E5=8A=A0=E6=89=80?= =?UTF-8?q?=E6=9C=89Tag=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/tag.html | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/templates/tag.html b/templates/tag.html index 5856db9..41b9d91 100644 --- a/templates/tag.html +++ b/templates/tag.html @@ -56,7 +56,7 @@ h1 a:not([href]){color:inherit;text-decoration:none;vertical-align: bottom;font- {% endblock %} {% block content %} -
{{ blogBase['subTitle'] }}
+
{% endblock %} @@ -68,6 +68,8 @@ document.getElementById("pathRSS").setAttribute("d",IconList["rss"]); document.getElementById("{{ blogBase['singeListJson'][num]['postTitle'] }}").setAttribute("d",value=IconList["{{ blogBase['singeListJson'][num]['label'] }}"]); {%- endfor %} +tag=window.location.hash.slice(1); +tagList=[]; let requestJson="blogBase.json" let request=new XMLHttpRequest(); request.open("GET",requestJson); @@ -79,12 +81,21 @@ request.onload=function(){ showList(jsonData); } -tag=window.location.hash.slice(1) - function showList(jsonData){ let SideNav=document.getElementsByClassName("SideNav")[0]; + let tagLable=document.getElementById("tagLable"); for(i in jsonData["postListJson"]){ + if(!(jsonData["postListJson"][i]['label'] in tagList)){ + tagList.push(jsonData["postListJson"][i]['label']); + let showLabels=document.createElement("span"); + showLabels.setAttribute("class","Label"); + showLabels.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']); + showLabels.innerHTML=jsonData["postListJson"][i]['label']; + showLabels.setAttribute("href",'#'+jsonData["postListJson"][i]['label']); + tagLable.appendChild(showLabels); + } + if(jsonData["postListJson"][i]['label']==tag || tag==''){ let item=document.createElement("a"); item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between");