Skip to content

Commit

Permalink
Merge pull request #497 from rebeccacremona/featured-tags
Browse files Browse the repository at this point in the history
Show "featured tags"  navigation on any paginated blog page.
  • Loading branch information
rebeccacremona authored Feb 23, 2024
2 parents 8b2c4af + cbefbad commit c4b9aaf
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ defaults:
custom-footer: false
sharing-card-type: summary

# Feature Flags
show_blog_featured_tags: true

############################################################
# Site configuration for the Jekyll 3 Pagination Gem
# The values here represent the defaults if nothing is set
Expand Down
3 changes: 3 additions & 0 deletions app/_data/featured_tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- link rot
- caselaw
- podcast
24 changes: 24 additions & 0 deletions app/_includes/tag-filter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% assign current = page.autopages.display_name|strip | default: 'all' %}

{% if site.show_blog_featured_tags %}

<div class="sleeve">
<nav class="posts-filter" aria-label="Featured Tags">
<ul>
<li>
<a class="tag" href="{{ site.baseurl }}/blog/"{% if current == "all" %} aria-current="true"{% endif %}>
all
</a>
</li>
{% for tag in site.data.featured_tags %}
<li>
<a class="tag" href="{{ site.baseurl }}/blog/tag/{{ tag | slugify}}/"{% if current == tag %} aria-current="true"{% endif %}>
{{ tag }}
</a>
</li>
{% endfor %}
</ul>
</nav>
</div>

{% endif %}
5 changes: 4 additions & 1 deletion app/_layouts/tag_or_category.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
---

<section class="posts-index">

{% include tag-filter.html %}

<div class="sleeve">
<h1>{{ page.autopages.display_name }}</h1>
<h1>Posts tagged: "{{ page.autopages.display_name }}"</h1>
{% for post in paginator.posts %}
<div class="slice">
<h2><time class="post-date" datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%B %-d, %Y" }}</time></h2>
Expand Down
42 changes: 39 additions & 3 deletions app/assets/css/blog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@
////////////////////////////////////////////////
// blog

.posts-filter {
text-align: left;
margin-top: 0;
margin-bottom: $double !important;

ul {
list-style-type: none;
padding: 0;
margin-bottom: 0;
}

li {
display: inline-block;
}

.tag {
border-bottom: none;
color: white;
}


}

.posts-index {
article {
Expand All @@ -21,7 +43,7 @@
border-bottom: none;
}

.sleeve:first-of-type article {
.sleeve:nth-of-type(2) article {
border-top: none;
margin-top: 0;
}
Expand Down Expand Up @@ -234,7 +256,7 @@
}

@include respond(4) {
article, .pagination {
article, .pagination, .posts-filter {
max-width: 596px;
margin: auto;
margin-top: 16px;
Expand Down Expand Up @@ -270,6 +292,20 @@ footer {
}
}

.tag[aria-current='true'] {
color: $color-white;
background-color: $color-electricblue;
a {
border-bottom: none;
}

&:hover, &:focus,
a:hover, a:focus {
color: $color-white;
background-color: $color-highlight;
}
}

figure.highlight pre {
overflow: scroll;
}
Expand Down Expand Up @@ -370,4 +406,4 @@ figure figcaption {
text-align: center;
display: block;
padding-top: 0.75rem;
}
}
4 changes: 2 additions & 2 deletions app/assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ h2 {
////////////////////////////////////////////////
// header

nav {
nav[aria-label="main"] {
text-align: center;

ul {
Expand Down Expand Up @@ -1315,7 +1315,7 @@ a.link-project {
}
}

nav {
nav[aria-label="main"] {
position: absolute;
bottom: 0;
left: 0;
Expand Down
3 changes: 3 additions & 0 deletions app/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
---

<section class="posts-index">

{% include tag-filter.html %}

{% for post in paginator.posts %}
<div class="sleeve">
<article itemscope itemtype="http://schema.org/BlogPosting">
Expand Down

0 comments on commit c4b9aaf

Please sign in to comment.