bmaupin / wiki

My wiki
https://bmaupin.github.io/wiki/
MIT License
11 stars 8 forks source link

Refactor duplicate liquid code into functions? #23

Open bmaupin opened 3 years ago

bmaupin commented 3 years ago

For example, when updating directory_title I had to do it in 6 places where we have the exact same logic:

$ grep -w capitalize -r
_includes/breadcrumbs.html:      {% assign directory_title = site_page.dir | split: '/' | last | capitalize | replace: "-", " " %}
_includes/sidebar-menu.md:        {%- assign directory_title = site_page.dir | split: '/' | last | capitalize | replace: "-", " " -%}
_includes/subpage-listing.md:        {%- assign directory_title = site_page.dir | split: '/' | last | capitalize | replace: "-", " " -%}
assets/js/pages.json:    {%- assign directory_title = page.dir | split: '/' | last | capitalize | replace: "-", " " -%}
_layouts/default.html:    {% assign directory_title = page.dir | split: '/' | last | capitalize | replace: "-", " " %}
_layouts/default.html:        {% assign directory_title = page.dir | split: '/' | last | capitalize | replace: "-", " " %}
bmaupin commented 3 years ago

https://jekyllrb.com/docs/plugins/filters/