JEKYLL HTML JAVASCRIPT

add-tag-count

image.png

μœ„μ™€ 같은 tag에 ν•΄λ‹Ήν•˜λŠ” 포슀트 수λ₯Ό κ΅¬ν˜„ν•˜κ³ μž ν•œλ‹€.


var js_categories = {{CATEGORY | split: ',' | join: ','}};
var js_category_list = {{CATEGORYS|split:','|join:','}};

// console.log(js_categories);
// console.log(js_category_list);

let js_category = {};
for (var now in js_category_list) {
    js_category[js_category_list[now]] = 0;
}
for (var now in js_categories) {
    var text = js_categories[now];
    js_category[text] = js_category[text] + 1;
}
// console.log(js_category);
for (var now in js_category) {
    var text = "(" + js_category[now] + ")";
    // console.log(text);
    document.getElementById(now).innerText =text;
}
//



liquid와 javaScriptλ₯Ό λ™μ‹œμ— μ‚¬μš©ν•˜κΈ°μ— ꡬ쑰적으둜 λ‚œν•΄ν•˜λ‹€.

const categories = { 
{% for category in site.categories %}
    {% capture category_name %}
    {{ category | first }}
    {% endcapture %}

    {{ category_name | replace: " ", "_" }}:

    [{% for post in site.categories[category_name] %}
            { url: `{{ site.baseurl }}{{ post.url }}`,
            date: `{{post.date | date_to_string}}`,
            title: `{{post.title}}`},
    {% endfor %}],
{% endfor %} }

μ‚¬μš©μ€‘μ΄λ˜ ν”„λ‘œκ·Έλž¨μ—μ„œ μ œμ‹œν•œ λ°©μ‹μ΄μ§€λ§Œ 이것은 더 λ‚œν•΄ν•˜κ³ , html + jekyll 지식이 더 ν•„μš”ν•œκ²ƒκ°™μ•„ λ‚˜μ€‘μ— μ΅μˆ™ν•΄μ§€λ©΄ ν•΄μ„ν•΄λ³΄κ³ μž ν•œλ‹€.