Add parameter for sorting project cards

This commit is contained in:
tterb 2019-03-04 23:17:51 -08:00
parent 7b775d501c
commit 223b6489b1
2 changed files with 12 additions and 1 deletions

View file

@ -15,6 +15,11 @@ defaults:
values:
layout: "post"
projects_sort_by: pushed
# Options:
# - pushed
# - stars
topics:
- name: CSS
web_url: https://github.com/topics/css

View file

@ -1,7 +1,13 @@
<h2 {% if site.style == 'dark' %}class="text-white"{% endif %}>My Projects</h2>
<p class="f4 mb-4 {% if site.style == 'dark' %}text-white{% else %}text-gray{% endif %}">GitHub repositories that I've built.</p>
<div class="d-sm-flex flex-wrap gutter-condensed mb-4">
{% for repository in site.github.public_repositories limit: 9 %}
{% if site.projects_sort_by == 'stars' %}
{% assign sort_order = 'stargazers_count', 'last' %}
{% else %}
{% assign sort_order = 'pushed_at' %}
{% endif %}
{% assign filtered_repos = site.github.public_repositories | sort: sort_order | reverse %}
{% for repository in filtered_repos | limit: 10 %}
<div class="col-sm-6 col-md-12 col-lg-6 col-xl-4 mb-3">
{% include repo-card.html %}
</div>