initial
This commit is contained in:
14
themes/next/layout/_macro/menu/menu-badge.swig
Normal file
14
themes/next/layout/_macro/menu/menu-badge.swig
Normal file
@ -0,0 +1,14 @@
|
||||
{% macro render(name) %}
|
||||
|
||||
{% set badges = {
|
||||
archives: site.posts.length,
|
||||
categories: site.categories.length,
|
||||
tags: site.tags.length }
|
||||
%}
|
||||
{% for menu, count in badges %}
|
||||
{% if name == menu %}
|
||||
<span class="badge">{{ count }}</span>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endmacro %}
|
24
themes/next/layout/_macro/menu/menu-item.swig
Normal file
24
themes/next/layout/_macro/menu/menu-item.swig
Normal file
@ -0,0 +1,24 @@
|
||||
{% macro render(name, value) %}
|
||||
{% import 'menu-badge.swig' as menu_badge %}
|
||||
|
||||
{% set itemURL = value.split('||')[0] | trim %}
|
||||
{% if itemURL.indexOf('http') != 0 %}
|
||||
{% set itemURL = itemURL | replace('//', '/', 'g') %}
|
||||
{% endif %}
|
||||
<li class="menu-item menu-item-{{ itemName | replace(' ', '-', 'g') }}{{ item_active(itemURL, 'menu-item-active') }}">
|
||||
|
||||
{% set menuText = __('menu.' + name) | replace('menu.', '') %}
|
||||
{% set menuURL = itemURL %}
|
||||
{% if theme.menu_settings.icons %}
|
||||
{% set menuIcon = '<i class="menu-item-icon fa fa-fw fa-' + value.split('||')[1] | trim | default('question-circle') + '"></i> <br/>' %}
|
||||
{% endif %}
|
||||
|
||||
{% if theme.menu_settings.badges %}
|
||||
{% set menuBadge = menu_badge.render(name) | trim %}
|
||||
{% endif %}
|
||||
|
||||
{{ next_url(menuURL, menuIcon + menuText + menuBadge, {rel: 'section'}) }}
|
||||
|
||||
</li>
|
||||
|
||||
{% endmacro %}
|
Reference in New Issue
Block a user