Skip to content

Commit

Permalink
feat: new config - enable footer_sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
papierkorp committed Nov 23, 2023
1 parent d301208 commit dc23e2c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 69 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ description: >- # this means to ignore newlines until
</p>
footer_sidebar:
enabled: true
auto: false # false = all elements will have the same width, true = each element takes what it needs
arrangement: # you can rearrange the positions of the elements
- description # will be the first one to be displayed
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ navigation:
url: /search.html

footer_sidebar:
enabled: true
auto: true
arrangement:
- description
Expand Down
140 changes: 71 additions & 69 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,79 @@
<footer>


{% if site.footer_sidebar.arrangement %}
<aside class="footer_sidebar footer_aside{% if site.footer_sidebar.auto %}_auto{% endif %}">
{% for section in site.footer_sidebar.arrangement %}
{% if section == 'description' and site.footer_sidebar.description.enabled %}
<section class="footer_sitedescription footer_sitedescription{% if site.footer_sidebar.description.columns and site.footer_sidebar.description.columns >= 0 and site.footer_sidebar.description.columns <= 5 %}{{site.footer_sidebar.description.columns}}{% else %}0{% endif %}">
{{ site.description }}
</section>
{% elsif section == 'customcontent' and site.footer_sidebar.customcontent.enabled %}
<section class="footer_customcontent footer_customcontent{% if site.footer_sidebar.customcontent.columns and site.footer_sidebar.customcontent.columns >= 0 and site.footer_sidebar.customcontent.columns <= 5 %}{{site.footer_sidebar.customcontent.columns}}{% else %}0{% endif %}">
{{ site.footer_sidebar.customcontent.data }}
</section>
{% elsif section == 'customcontent2' and site.footer_sidebar.customcontent2.enabled %}
<section class="footer_customcontent2 footer_customcontent2{% if site.footer_sidebar.customcontent2.columns and site.footer_sidebar.customcontent2.columns >= 0 and site.footer_sidebar.customcontent2.columns <= 5 %}{{site.footer_sidebar.customcontent2.columns}}{% else %}0{% endif %}">
{{ site.footer_sidebar.customcontent2.data }}
</section>
{% elsif section == 'categories' and site.footer_sidebar.categories.enabled %}
<section class="footer_categories footer_categories{% if site.footer_sidebar.categories.columns and site.footer_sidebar.categories.columns >= 0 and site.footer_sidebar.categories.columns <= 5 %}{{site.footer_sidebar.categories.columns}}{% else %}0{% endif %}">
<h3>Categories</h3>
<ul>
{% assign all_categories = "" %}
{% for post in site.posts %}
{% assign post_categories = post.categories %}
{% for category in post_categories %}
{% assign all_categories = all_categories | append: category | append: "," %}
{% if site.footer_sidebar.enabled %}
{% if site.footer_sidebar.arrangement %}
<aside class="footer_sidebar footer_aside{% if site.footer_sidebar.auto %}_auto{% endif %}">
{% for section in site.footer_sidebar.arrangement %}
{% if section == 'description' and site.footer_sidebar.description.enabled %}
<section class="footer_sitedescription footer_sitedescription{% if site.footer_sidebar.description.columns and site.footer_sidebar.description.columns >= 0 and site.footer_sidebar.description.columns <= 5 %}{{site.footer_sidebar.description.columns}}{% else %}0{% endif %}">
{{ site.description }}
</section>
{% elsif section == 'customcontent' and site.footer_sidebar.customcontent.enabled %}
<section class="footer_customcontent footer_customcontent{% if site.footer_sidebar.customcontent.columns and site.footer_sidebar.customcontent.columns >= 0 and site.footer_sidebar.customcontent.columns <= 5 %}{{site.footer_sidebar.customcontent.columns}}{% else %}0{% endif %}">
{{ site.footer_sidebar.customcontent.data }}
</section>
{% elsif section == 'customcontent2' and site.footer_sidebar.customcontent2.enabled %}
<section class="footer_customcontent2 footer_customcontent2{% if site.footer_sidebar.customcontent2.columns and site.footer_sidebar.customcontent2.columns >= 0 and site.footer_sidebar.customcontent2.columns <= 5 %}{{site.footer_sidebar.customcontent2.columns}}{% else %}0{% endif %}">
{{ site.footer_sidebar.customcontent2.data }}
</section>
{% elsif section == 'categories' and site.footer_sidebar.categories.enabled %}
<section class="footer_categories footer_categories{% if site.footer_sidebar.categories.columns and site.footer_sidebar.categories.columns >= 0 and site.footer_sidebar.categories.columns <= 5 %}{{site.footer_sidebar.categories.columns}}{% else %}0{% endif %}">
<h3>Categories</h3>
<ul>
{% assign all_categories = "" %}
{% for post in site.posts %}
{% assign post_categories = post.categories %}
{% for category in post_categories %}
{% assign all_categories = all_categories | append: category | append: "," %}
{% endfor %}
{% endfor %}
{% endfor %}
{% assign unique_categories = all_categories | split: "," | uniq %}

{% assign categories_count = site.footer_sidebar.categories.count | default: 100 %}
{% assign categories_to_display = unique_categories | slice: 0, categories_count %}

{% for category in categories_to_display %}
<li><a href="{{ site.baseurl }}/categories.html#{{ category }}">{{ category }}</a></li>
{% endfor %}
</ul>
</section>
{% elsif section == 'tags' and site.footer_sidebar.tags.enabled %}
<section class="footer_tags footer_tags{% if site.footer_sidebar.tags.columns and site.footer_sidebar.tags.columns >= 0 and site.footer_sidebar.tags.columns <= 5 %}{{site.footer_sidebar.tags.columns}}{% else %}0{% endif %}">
<h3>Tags</h3>
<ul>
{% assign all_tags = "" %}
{% for post in site.posts %}
{% assign post_tags = post.tags %}
{% for tag in post_tags %}
{% assign all_tags = all_tags | append: tag | append: "," %}
{% assign unique_categories = all_categories | split: "," | uniq %}

{% assign categories_count = site.footer_sidebar.categories.count | default: 100 %}
{% assign categories_to_display = unique_categories | slice: 0, categories_count %}

{% for category in categories_to_display %}
<li><a href="{{ site.baseurl }}/categories.html#{{ category }}">{{ category }}</a></li>
{% endfor %}
{% endfor %}
{% assign unique_tags = all_tags | split: "," | uniq %}

{% assign tags_count = site.footer_sidebar.tags.count | default: 100 %}
{% assign tags_to_display = unique_tags | slice: 0, tags_count %}

{% for tag in tags_to_display %}
<li><a href="{{ site.baseurl }}/tags#{{ tag }}">{{ tag }}</a></li>
{% endfor %}
</ul>
</section>
{% elsif section == 'recentposts' and site.footer_sidebar.recentposts.enabled %}
<section class="footer_recentposts footer_recentposts{% if site.footer_sidebar.recentposts.columns and site.footer_sidebar.recentposts.columns >= 0 and site.footer_sidebar.recentposts.columns <= 5 %}{{site.footer_sidebar.recentposts.columns}}{% else %}0{% endif %}">
<h3>Recent Posts</h3>
<ul>
{% assign recentposts_count = site.footer_sidebar.recentposts.count | default: 5 %}
{% assign recent_posts = site.posts | reverse %}
{% for post in recent_posts limit:recentposts_count %}
<li><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</section>
{% endif %}
{% endfor %}
</aside>
</ul>
</section>
{% elsif section == 'tags' and site.footer_sidebar.tags.enabled %}
<section class="footer_tags footer_tags{% if site.footer_sidebar.tags.columns and site.footer_sidebar.tags.columns >= 0 and site.footer_sidebar.tags.columns <= 5 %}{{site.footer_sidebar.tags.columns}}{% else %}0{% endif %}">
<h3>Tags</h3>
<ul>
{% assign all_tags = "" %}
{% for post in site.posts %}
{% assign post_tags = post.tags %}
{% for tag in post_tags %}
{% assign all_tags = all_tags | append: tag | append: "," %}
{% endfor %}
{% endfor %}
{% assign unique_tags = all_tags | split: "," | uniq %}

{% assign tags_count = site.footer_sidebar.tags.count | default: 100 %}
{% assign tags_to_display = unique_tags | slice: 0, tags_count %}

{% for tag in tags_to_display %}
<li><a href="{{ site.baseurl }}/tags#{{ tag }}">{{ tag }}</a></li>
{% endfor %}
</ul>
</section>
{% elsif section == 'recentposts' and site.footer_sidebar.recentposts.enabled %}
<section class="footer_recentposts footer_recentposts{% if site.footer_sidebar.recentposts.columns and site.footer_sidebar.recentposts.columns >= 0 and site.footer_sidebar.recentposts.columns <= 5 %}{{site.footer_sidebar.recentposts.columns}}{% else %}0{% endif %}">
<h3>Recent Posts</h3>
<ul>
{% assign recentposts_count = site.footer_sidebar.recentposts.count | default: 5 %}
{% assign recent_posts = site.posts | reverse %}
{% for post in recent_posts limit:recentposts_count %}
<li><a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
</section>
{% endif %}
{% endfor %}
</aside>
{% endif %}
{% endif %}


Expand Down

0 comments on commit dc23e2c

Please sign in to comment.