Skip to content

Commit be79a61

Browse files
committed
Split project list into a partial to use on multiple pages
1 parent 4dd5c78 commit be79a61

File tree

3 files changed

+61
-51
lines changed

3 files changed

+61
-51
lines changed

_includes/project-list.html

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<ul class="card-grid">
2+
{% assign public_repositories = site.github.public_repositories | where:'archived', false | where:'fork', false | sort: 'stargazers_count' | reverse %}
3+
4+
<!-- Assign an optional limit to be passed through -->
5+
{% for repository in public_repositories limit: {{include.limit}} %}
6+
7+
<!-- Assign theme colors based of off the project language -->
8+
<!-- See include below for logic and color.scss for available themes -->
9+
{% include project-color-logic.html %}
10+
11+
<li class="card theme-{{ theme | default: "midnight" }}">
12+
<header class="card__header">
13+
14+
<!-- Project title -->
15+
<h2 class="card__header-title">
16+
<a class="card__header-link stretched-link" href='{{ repository.html_url }}'>
17+
{{ repository.name }}
18+
</a>
19+
</h2>
20+
21+
<!-- Project metadata -->
22+
<ul class="card__header-list list--inline fs-md monospace">
23+
{% if repository.language %}
24+
<li>
25+
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#code' | relative_url }}"></use></svg><span class="visually-hidden">Language: </span>{{ repository.language }}
26+
</li>
27+
{% endif %}
28+
29+
{% if repository.license.spdx_id %}
30+
<li>
31+
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#license' | relative_url }}"></use></svg><span class="visually-hidden">License: </span>{{ repository.license.spdx_id }}
32+
</li>
33+
{% endif %}
34+
</ul>
35+
36+
<!-- External Link Indicator -->
37+
<div class="card__external-indicator">
38+
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-external' | relative_url }}"></use></svg>
39+
</div>
40+
</header>
41+
42+
<!-- Project description -->
43+
<div class="card__body fs-md monospace" aria-hidden="true">
44+
{% if repository.description %}
45+
<p class="m-0 clamp-3">{{ repository.description }}</p>
46+
{% endif %}
47+
</div>
48+
</li>
49+
50+
{% endfor %}
51+
</ul>

_layouts/home.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22
layout: default
33
---
44

5-
This is an empty homepage.
5+
6+
<section class="section-container">
7+
<h2 id="featured-projects" class="section-heading pb-3">Featured Projects</h2>
8+
{% include project-list.html limit="3" %}
9+
<a href="{% link projects.html %}" class="mt-4 btn btn-secondary btn-icon-right">
10+
All Projects
11+
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-right' | relative_url }}"></use></svg>
12+
</a>
13+
</section>

projects.html

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,5 @@
1111

1212
<div class="section-container">
1313
<h2 class="mb-3">Open Source Projects</h2>
14-
15-
<ul class="card-grid mb-3">
16-
{% assign public_repositories = site.github.public_repositories | where:'archived', false | where:'fork', false | sort: 'stargazers_count' | reverse %}
17-
{% for repository in public_repositories %}
18-
19-
<!-- Assign theme colors based of off the project language -->
20-
<!-- See include below for logic and color.scss for available themes -->
21-
{% include project-color-logic.html %}
22-
23-
<li class="card theme-{{ theme | default: "midnight" }}">
24-
<header class="card__header">
25-
26-
<!-- Project title -->
27-
<h2 class="card__header-title">
28-
<a class="card__header-link stretched-link" href='{{ repository.html_url }}'>
29-
{{ repository.name }}
30-
</a>
31-
</h2>
32-
33-
<!-- Project metadata -->
34-
<ul class="card__header-list list--inline fs-md monospace">
35-
{% if repository.language %}
36-
<li>
37-
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#code' | relative_url }}"></use></svg><span class="visually-hidden">Language: </span>{{ repository.language }}
38-
</li>
39-
{% endif %}
40-
41-
{% if repository.license.spdx_id %}
42-
<li>
43-
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#license' | relative_url }}"></use></svg><span class="visually-hidden">License: </span>{{ repository.license.spdx_id }}
44-
</li>
45-
{% endif %}
46-
</ul>
47-
48-
<!-- External Link Indicator -->
49-
<div class="card__external-indicator">
50-
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-external' | relative_url }}"></use></svg>
51-
</div>
52-
</header>
53-
54-
<!-- Project description -->
55-
<div class="card__body fs-md monospace" aria-hidden="true">
56-
{% if repository.description %}
57-
<p class="m-0 clamp-3">{{ repository.description }}</p>
58-
{% endif %}
59-
</div>
60-
</li>
61-
62-
{% endfor %}
63-
</ul>
14+
{% include project-list.html %}
6415
</div>

0 commit comments

Comments
 (0)