{% comment %} Renders the leading icons of a post, from its `title_icons` front matter: title_icons: # the icons themselves, in display order - 📗 - 👨🏽‍🏫 title_icons_count: # how many icons each surface shows; 0 hides them homepages: 2 opened: 2 recommended: 0 related: 0 title: 1 Each `title_icons_count` value is a count taken from the front of the list, so one surface can show fewer icons than another. Zero hides them there. Counts are a separate key from the list on purpose: Jekyll merges front-matter defaults shallowly, so had they been nested inside `title_icons`, any page declaring its own list would wipe out the counts inherited from _config.yml. Site-wide counts are set for every page through `defaults` in _config.yml; a page may override them in its own front matter. A surface left unset shows every icon in the list. Parameters: post - the post object whose icons to render (`page` on a post page) context - the surface asking: homepages | opened | recommended | related | title plain - truthy to emit bare text plus a trailing space instead of the wrapper. Required inside , which takes no markup. Surfaces: homepages - the post list on the home page opened - the title of the opened post itself recommended - the featured/pinned posts panel in the right sidebar related - the "related posts" cards at the bottom of a post title - the <title> element, i.e. the browser tab / bookmark label {% endcomment %} {%- assign icon_list = include.post.title_icons -%} {%- if icon_list and icon_list.size > 0 -%} {%- comment -%} Per-post count wins; `== nil` keeps an explicit 0 usable. {%- endcomment -%} {%- assign count = include.post.title_icons_count[include.context] -%} {%- if count == nil -%} {%- assign count = icon_list.size -%} {%- endif -%} {%- if count > 0 -%} {%- comment -%} `join` rather than a loop with a literal space: Liquid's whitespace control swallowed the separator, gluing the icons together. {%- endcomment -%} {%- assign shown_icons = icon_list | slice: 0, count -%} {%- assign icons_text = shown_icons | join: ' ' -%} {%- comment -%} <title> takes no markup, so `plain` skips the wrapper and carries its own trailing space (the span gets its gap from CSS instead, which survives the production whitespace stripping). {%- endcomment -%} {%- if include.plain -%}{{ icons_text }} {% else %}<span class="post-icons">{{ icons_text }}</span>{%- endif -%} {%- endif -%} {%- endif -%}