-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
498feb9
commit f19a1f2
Showing
10 changed files
with
104 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const tags = document.getElementById('tags') | ||
const tagsBtn = document.getElementById('tags-btn') | ||
const arrayTags = Array.from(tags.children) | ||
const arrayTagsBtn = Array.from(tagsBtn.children) | ||
|
||
const urlParams = new URLSearchParams(window.location.search); | ||
const tagParam = urlParams.get('tag'); | ||
|
||
let prevActiveTag = arrayTags[0] | ||
let prevActiveBtnTag = arrayTagsBtn[0] | ||
|
||
if (tagParam !== null) { | ||
const targetElement = arrayTags.find(elm => elm.id === tagParam); | ||
const targetBtn = arrayTagsBtn.find(elm => elm.getAttribute('data-tag') === tagParam); | ||
targetBtn.classList.add("flex") | ||
targetElement.classList.remove("hidden") | ||
targetBtn.classList.add("border-[1px]", "border-slate-300") | ||
prevActiveTag = targetElement | ||
prevActiveBtnTag = targetBtn | ||
} else { | ||
arrayTags[0].classList.add("flex") | ||
arrayTags[0].classList.remove("hidden") | ||
arrayTagsBtn[0].classList.add("border-[1px]", "border-slate-300") | ||
} | ||
|
||
arrayTagsBtn.forEach((btn) => { | ||
btn.addEventListener("click", () => { | ||
id = btn.getAttribute('data-tag') | ||
const targetElement = arrayTags.find(elm => elm.id === id); | ||
|
||
prevActiveBtnTag.classList.remove("border-[1px]", "border-slate-300") | ||
prevActiveTag.classList.remove("flex") | ||
prevActiveTag.classList.add("hidden") | ||
|
||
prevActiveTag = targetElement | ||
prevActiveBtnTag = btn | ||
|
||
btn.classList.add("border-[1px]", "border-slate-300") | ||
targetElement.classList.add("flex") | ||
targetElement.classList.remove("hidden") | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
--- | ||
layout: blog | ||
title: Kadafi's Blog | ||
permalink: /blog | ||
--- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
layout: blog | ||
permalink: /blog/tags | ||
--- | ||
|
||
<div class="px-8"> | ||
<div id="tags-btn" | ||
class="flex flex-wrap mt-20 mx-auto bg-slate-400/70 border-slate-200 dark:bg-slate-700/70 backdrop-blur-md dark:border-slate-500 border-[1px] p-3 rounded-md shadow-custom lg:w-5/6""> | ||
|
||
{% for tag in site.tags %} | ||
<span id=" category-btn" class=" cursor-pointer inline-block mr-2 my-2 text-sm w-fit bg-slate-500/70 | ||
backdrop-blur-md rounded-xl px-3 py-[2px] text-slate-200" data-tag="{{ tag[0] }}"> | ||
{{ tag[0] | capitalize }} | ||
</span> | ||
|
||
{% endfor %} | ||
|
||
</div> | ||
|
||
<div id="tags" class="w-full dark:text-white"> | ||
{% for tag in site.tags %} | ||
<section id="{{tag[0]}}" class="lg:px-5 hidden flex-col justify-center items-center pt-20"> | ||
<div class="text-center mb-5"> | ||
<h1 | ||
class="text-2xl lg:text-3xl font-bold mb-3 after:content-[''] after:h-[2px] after:w-10 after:block after:mx-auto after:bg-black after:dark:bg-white"> | ||
{{tag[0] | capitalize}} | ||
</h1> | ||
<p class="w-3/5">{{page.desc}}</p> | ||
</div> | ||
<div class="w-full mb-10 grid md:grid-cols-2 lg:grid-cols-3 justify-center items-center gap-5"> | ||
{% for post in tag[1] %} | ||
{% include blog-post-card.html post=post %} | ||
{% endfor %} | ||
</div> | ||
</section> | ||
{% endfor %} | ||
</div> | ||
</div> |