{% extends "til_base.html" %} {% block title %}TIL{% endblock %} {% block extra_head %} {% endblock %} {% block body %} {% set snippet_path = '_snippets_index.md' %} {% include 'snippet_display.html' %} {% set til_count = sql("select count(*) from TIL", database="tils")[0][0] %}
{%- set unique_topics = {} %} {%- for topic_row in sql("SELECT DISTINCT topics FROM til", database="tils") %} {%- if topic_row.topics %} {%- for topic in topic_row.topics.split(',') %} {%- if topic.strip() and not unique_topics.get(topic.strip()) %} {%- set count = sql("SELECT COUNT(*) as count FROM til WHERE topics LIKE '%" + topic.strip() + "%'", database="tils")[0].count %} {%- if unique_topics.update({topic.strip(): count}) -%}{%- endif %} {%- endif %} {%- endfor %} {%- endif %} {%- endfor %} {%- for topic in unique_topics.keys()|sort %} {{ topic }} {{ unique_topics[topic] }}{% if not loop.last %} · {% endif %} {%- endfor %}