blog.trnck.dev
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #61 from tterb/project-parameters

Add _config.yml parameters for sorting and excluding projects

authored by

Brandon Rosage and committed by
GitHub
73231a93 8eaf09c3

+41 -5
+12
README.md
··· 73 73 74 74 Your website appears with a "light" white and gray background by default, with dark text. You can quickly switch to a "dark" background with white text by changing the line in your `_config.yml` file that reads `style: light` to `style: dark`. 75 75 76 + #### Projects 77 + 78 + The "My Projects" section of your website is generated by default with your nine most recently "pushed" repositories. It also excludes repositories that you forked, by default. But each of these parameters can be quickly customized in your repository's `_config.yml` file, under the `projects` dictionary line. 79 + 80 + Parameters include: 81 + 82 + - `sort_by`: The method by which repositories are sorted. Options include `pushed` and `stars`. 83 + - `limit`: The maximum number of repositories that will be displayed in the "My Projects" section of your website. Out of the box, this number is set to `9`. 84 + - `exclude`: 85 + - `forks`: When `true`, repositories you've forked will be excluded from the listing. 86 + - `projects`: A list the repository names you want to exclude from the listing. 87 + 76 88 #### Topics 77 89 78 90 Your website comes pre-configured with three topics (e.g. "Web design" and "Sass") that appear in a section titled "My Interests." These are also stored in your repository's `_config.yml` file, where you can define each topic's name and two other optional details:
+11
_config.yml
··· 16 16 values: 17 17 layout: "post" 18 18 19 + projects: 20 + sort_by: pushed 21 + # sort_by options: 22 + # - pushed 23 + # - stars 24 + limit: 9 25 + exclude: 26 + forks: true 27 + projects: 28 + # - repo-name 29 + 19 30 topics: 20 31 - name: CSS 21 32 web_url: https://github.com/topics/css
+18 -5
_includes/projects.html
··· 1 1 <h2 {% if site.style == 'dark' %}class="text-white"{% endif %}>My Projects</h2> 2 2 <p class="f4 mb-4 {% if site.style == 'dark' %}text-white{% else %}text-gray{% endif %}">GitHub repositories that I've built.</p> 3 3 <div class="d-sm-flex flex-wrap gutter-condensed mb-4"> 4 - {% assign public_repositories = site.github.public_repositories | sort: 'pushed_at' | reverse %} 5 - {% for repository in public_repositories limit: 9 %} 6 - <div class="col-sm-6 col-md-12 col-lg-6 col-xl-4 mb-3"> 7 - {% include repo-card.html %} 8 - </div> 4 + {% if site.projects.sort_by == 'stars' %} 5 + {% assign sort_order = 'stargazers_count', 'last' %} 6 + {% else %} 7 + {% assign sort_order = 'pushed_at' %} 8 + {% endif %} 9 + 10 + {% if site.projects.exclude.forks %} 11 + {% assign filtered_repos = site.github.public_repositories | where:'fork', false | sort: sort_order | reverse %} 12 + {% else %} 13 + {% assign filtered_repos = site.github.public_repositories | sort: sort_order | reverse %} 14 + {% endif %} 15 + 16 + {% for repository in filtered_repos | limit: site.projects.limit %} 17 + {% unless site.projects.exclude.projects contains repository.name %} 18 + <div class="col-sm-6 col-md-12 col-lg-6 col-xl-4 mb-3"> 19 + {% include repo-card.html %} 20 + </div> 21 + {% endunless %} 9 22 {% endfor %} 10 23 </div>