Skip to content

Commit

Permalink
script 중복 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
5eonhee committed Feb 21, 2023
1 parent d7f7244 commit 8816051
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
21 changes: 1 addition & 20 deletions _includes/post-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,4 @@ <h1 class="catalogue-title">
{% endfor %}
{% endif %}
</ul>
</div>

<script>
$('[data-tag]').click((e) => {
currentTag = e.target.dataset.tag;
filterByTagName(currentTag);
})

function filterByTagName(tagName) {
$('.catalogue-item.hidden').removeClass('hidden');
$('.catalogue-item').each((index, elem) => {

if (!elem.hasAttribute('data-' + tagName)) {
$(elem).addClass('hidden');
}
});
$('.tag').removeClass('selected');
$('.tag[data-tag=' + tagName+']').addClass('selected');
}
</script>
</div>
21 changes: 20 additions & 1 deletion tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,23 @@ project-header: true
{% include post-list.html %}
{% endif %}
{% endfor %}
</div>
</div>

<script>
$('[data-tag]').click((e) => {
currentTag = e.target.dataset.tag;
filterByTagName(currentTag);
})

function filterByTagName(tagName) {
$('.catalogue-item.hidden').removeClass('hidden');
$('.catalogue-item').each((index, elem) => {

if (!elem.hasAttribute('data-' + tagName)) {
$(elem).addClass('hidden');
}
});
$('.tag').removeClass('selected');
$('.tag[data-tag=' + tagName+']').addClass('selected');
}
</script>

0 comments on commit 8816051

Please sign in to comment.