Multiple Grav tweaks

grav

Switch to Quark theme

Based on this page I made some tweaks after switching from Antimatter to Quark.

Add the number of posts with a given tag

Editing themes/quark/templates/partials/taxonomy.html.twig

{#
{% set taxlist = children_only is defined ? taxonomylist.getChildPagesTags(of_page, children_only) : taxonomylist.get() %}
#}
{% set taxlist = taxonomylist.get() %}

{% if taxlist %}
<span class="tags">
    {% for tax, value in taxlist[taxonomy] %} 
        {% set active = uri.param(taxonomy) == tax ? 'active' : '' %}
     {% set label_class = uri.param(taxonomy) == tax ? 'label-primary' : 'label-secondary' %}
     <a class="label label-rounded {{ label_class }}" href="{{ base_url }}/{{ taxonomy }}{{ config.system.param_sep }}{{ tax }}">{{ tax|upper }} ({{value}})</a>
    {% endfor %}
</span>
{% endif %}
{{ dump(taxlist)}}

Getting archives to show year only

The archives plugin shows, by default, month and year which is a long list for 20 years of posts. Changing it to years only is described in the README.md file linked to from the plugin page but the necessary adjustments to the .twig file are wrong. I found a corrected version in the forum but am unable to find that post again to link to. The commented out lines simply create an unordered list of the years rather than a single wrapped line.


<ul class="archives">
{% for year,items in archives_data %}
{#    <li> #}
        {% if archives_show_count %}
    <a href="{{ archives_url ?? base_url }}/{{ config.plugins.archives.taxonomy
_names.year }}{{ config.system.param_sep }}{{ year|lower|e('url') }}">

        {% endif %}
        <span class="label label-rounded label-secondary">{{ year }} <span class="l
abel"> {{ items|length }}</span> </span>
        </a>
{#    </li>#}
{% endfor %}
</ul>

Previous Post