Skip to content

Commit 465ccf0

Browse files
authored
Merge pull request scribd#28 from scribd/category-navigation
Category navigation
2 parents 23635f6 + 9b1b245 commit 465ccf0

16 files changed

+231
-63
lines changed

_category/core-platform.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
team: Core Platform
3+
permalink: "/blog/category/core-platform"
4+
---

_category/data-science.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
team: Data Science
3+
permalink: "/blog/category/data-science"
4+
---

_category/ios.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
team: iOS
3+
permalink: "/blog/category/ios"
4+
---

_category/web-development.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
team: Web Development
3+
permalink: "/blog/category/web-development"
4+
---

_config.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,22 @@ permalink: "/blog/:year/:title:output_ext"
3232
date_format: "%B %-d, %Y"
3333
paginate: 12
3434
paginate_path: "/blog/page:num/"
35+
post-id: "#posts"
3536

3637
# Build settings
3738
plugins:
3839
- jekyll-feed
3940
- jekyll-paginate
4041

41-
# Exclude from processing.
42-
# The following items will not be processed, by default.
43-
# Any item listed under the `exclude:` key here will be automatically added to
44-
# the internal "default list".
45-
#
46-
# Excluded items can be processed by explicitly listing the directories or
47-
# their entries' file path in the `include:` list.
48-
#
49-
# exclude:
50-
# - .sass-cache/
51-
# - .jekyll-cache/
52-
# - gemfiles/
53-
# - Gemfile
54-
# - Gemfile.lock
55-
# - node_modules/
56-
# - vendor/bundle/
57-
# - vendor/cache/
58-
# - vendor/gems/
59-
# - vendor/ruby/
42+
# Blog categories
43+
collections:
44+
category:
45+
output: true
46+
47+
defaults:
48+
-
49+
scope:
50+
path: ""
51+
type: category
52+
values:
53+
layout: "category"

_includes/featured-post-hero.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h3 class="section-heading mb-0 text-plum">Featured Series</h3>
6969

7070
<!-- All posts button (if not on a blog page already) -->
7171
{% unless page.url contains "blog" %}
72-
<a href="{% link blog/index.html %}#all-posts" class="mt-4 btn btn-primary btn-icon-right">
72+
<a href="{% link blog/index.html %}{{ site.post-id }}" class="mt-4 btn btn-primary btn-icon-right">
7373
All Posts
7474
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-right' | relative_url }}"></use></svg>
7575
</a>

_includes/pagination.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<!-- Previous arrow -->
66
{% if paginator.previous_page %}
77
<li class="pagination__item">
8-
<a class="older-posts" href="{{ paginator.previous_page_path | relative_url }}">
8+
<a class="pagination__link" href="{{ paginator.previous_page_path | relative_url }}{{ site.post-id }}">
99
<span class="visually-hidden">Previous Page</span>
1010
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-left' | relative_url }}"></use></svg>
1111
</a>
@@ -24,13 +24,13 @@
2424

2525
<!-- Page 1 -->
2626
{% if page == 1 %}
27-
<a class="pagination__link {{ class }}" href="{{ paginator.previous_page_path | relative_url }}" {{ aria }}>
27+
<a class="pagination__link {{ class }}" href="{{ paginator.previous_page_path | relative_url }}{{ site.post-id }}" {{ aria }}>
2828
<span class="visually-hidden">Page </span>{{ page }}
2929
</a>
3030

3131
<!-- Page 2, 3, 4, etc -->
3232
{% else %}
33-
<a class="pagination__link {{ class }}" href="{{ site.paginate_path | relative_url | replace: ':num', page }}" {{ aria }}>
33+
<a class="pagination__link {{ class }}" href="{{ site.paginate_path | relative_url | replace: ':num', page }}{{ site.post-id }}" {{ aria }}>
3434
<span class="visually-hidden">Page </span>{{ page }}
3535
</a>
3636

@@ -41,7 +41,7 @@
4141
<!-- Next arrow -->
4242
{% if paginator.next_page %}
4343
<li class="pagination__item">
44-
<a class="older-posts" href="{{ paginator.next_page_path | relative_url }}">
44+
<a class="pagination__link" href="{{ paginator.next_page_path | relative_url }}{{ site.post-id }}">
4545
<span class="visually-hidden">Next Page</span>
4646
<svg class="svg-icon"><use xlink:href="{{ '/assets/images/icons/icon-sprite.svg#arrow-right' | relative_url }}"></use></svg>
4747
</a>

_layouts/category.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
layout: post-index
3+
title: page.team
4+
---
5+
6+
<ul class="post-list text-length-lg">
7+
8+
<!-- Loop though posts -->
9+
{% for post in site.posts %}
10+
{% capture team %}{{post.team}}{% endcapture %}
11+
{% if team == page.team %}
12+
{% include post-list-item.html %}
13+
{% endif %}
14+
{% endfor %}
15+
16+
</ul>

_layouts/default.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<!DOCTYPE html>
2-
<html lang="{{ page.lang | default: site.lang | default: "en" }}">
2+
{% if page.url contains "/category" or page.url contains "/page" or page.url == "/blog/" %}
3+
{% assign class = 'no-smooth-scroll' %}
4+
{% endif %}
5+
<html class="{{ class }}" lang="{{ page.lang | default: site.lang | default: "en" }}">
36
{%- include head.html -%}
47
<body>
58
{%- include header.html -%}

_layouts/post-index.html

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
layout: default
3+
---
4+
5+
<!-- Featured post hero -->
6+
{% include featured-post-hero.html %}
7+
8+
<div class="post-index" id="{{ site.post-id | remove: "#" }}">
9+
10+
<!-- Post catagory nav -->
11+
<nav class="post-index__nav text-white" aria-label="Blog Categories">
12+
13+
<ul class="post-index__nav-list list--plain">
14+
15+
{% unless page.url contains "category" %}
16+
{% assign class = 'active' %}
17+
{% endunless %}
18+
19+
<!-- Blog home -->
20+
<li class="post-index__nav-list-item {{ class }}">
21+
<a class="post-index__nav-link" href="{% link blog/index.html %}{{ site.post-id }}">Latest</a>
22+
</li>
23+
24+
<!-- Catagory loop -->
25+
{% for category in site.category %}
26+
{% assign class = nil %}
27+
{% if page.url contains category.url or page.url contains category.title or page.url == "/blog/index.html" %}
28+
{% assign class = 'active' %}
29+
{% endif %}
30+
31+
<li class="post-index__nav-list-item {{ class }}">
32+
<a class="post-index__nav-link" href="{{ category.url }}{{ site.post-id }}">{{ category.team }}</a>
33+
</li>
34+
{% endfor %}
35+
</ul>
36+
37+
</nav>
38+
39+
<section class="post-index__body">
40+
41+
<!-- Post catagory title -->
42+
<div class="pb-2 border-bottom text-length-lg">
43+
{% assign catagory-title = 'Latest' %}
44+
{% if page.team %}
45+
{% assign catagory-title = page.team %}
46+
{% endif %}
47+
<h1 class="section-heading text-teal">{{catagory-title}} Posts</h1>
48+
</div>
49+
50+
<!-- Content -->
51+
<div class="text-length-lg">
52+
{{ content }}
53+
</div>
54+
55+
<!-- Pagination -->
56+
{% include pagination.html %}
57+
</section>
58+
59+
</div>

0 commit comments

Comments
 (0)