Skip to content

Latest commit

 

History

History
40 lines (35 loc) · 1.16 KB

File metadata and controls

40 lines (35 loc) · 1.16 KB
layout base
title News
description News & blog posts
permalink /blog/
{% for item in site.posts %}
{% include card.html %}
{% endfor %}
<script> // Filter cards on ?tag=value $(document).ready(function() { const urlParams = new URLSearchParams(window.location.search); if (urlParams.has("tag") && urlParams.get("tag") != "") { const tag = urlParams.get("tag"); // Will return 1st tag value + decode URI const cleanTag = $.trim(tag.toLowerCase()); // Create tag as written in .card data-tags $(".card").each(function() { const cardTags = $(this).data("tags").split("|"); // Hide card if it does not contain the selected tag if (!cardTags.includes(cleanTag)) { $(this).parent().addClass("d-none"); } }); $(".header .tags").append( '' + tag + '' + '' ); } }); </script>