Skip to content

Commit aa0bb04

Browse files
committed
Use collections to improve the tabs
1 parent 4208bae commit aa0bb04

File tree

11 files changed

+66
-89
lines changed

11 files changed

+66
-89
lines changed

_config.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ description: >- # used by seo meta and the atom feed
1717
bootstrap Jekyll theme with responsive web design
1818
and focuses on text presentation.
1919
20-
# Replace with the website url, e.g. 'https://username.github.io'
21-
url: 'protocol://domain'
20+
# fill in the base hostname & protocol for your site, e.g., 'https://username.github.io'
21+
url: ''
2222

2323
author: your_full_name # change to your full name
2424

@@ -80,7 +80,7 @@ disqus:
8080
#
8181
theme_mode: dual
8282

83-
# boolean type, global switch for ToC in posts.
83+
# boolean type, the global switch for ToC in posts.
8484
toc: true
8585

8686
paginate: 10
@@ -105,16 +105,21 @@ kramdown:
105105
# or you think you're smart enough to change other relevant URLs within this template.
106106
permalink: /posts/:title/
107107

108+
collections:
109+
tabs:
110+
output: true
111+
sort_by: order
112+
113+
108114
defaults:
109115
-
110116
scope:
111-
path: "" # An empty string here means all files in the project
117+
path: '' # An empty string here means all files in the project
112118
type: posts
113119
values:
114120
layout: post
115121
comments: true # Enable comments in posts.
116122
toc: true # Display TOC column in posts.
117-
location: Post
118123
breadcrumb:
119124
-
120125
label: Posts
@@ -128,8 +133,6 @@ defaults:
128133
scope:
129134
path: tags
130135
values:
131-
tab_active: Tags
132-
location: Tag
133136
breadcrumb:
134137
-
135138
label: Home
@@ -141,8 +144,6 @@ defaults:
141144
scope:
142145
path: categories
143146
values:
144-
tab_active: Categories
145-
location: Category
146147
breadcrumb:
147148
-
148149
label: Home
@@ -152,7 +153,8 @@ defaults:
152153
url: /tabs/categories/
153154
-
154155
scope:
155-
path: tabs
156+
path: ''
157+
type: tabs # see `site.collections`
156158
values:
157159
layout: page
158160
dynamic_title: true # Hide title in mobile screens.

_data/tabs.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

_includes/css-selector.html

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@
1212

1313
{% elsif page.layout == 'page' %}
1414

15-
{% if page.type == 'categories' %}
16-
17-
<link rel="preload" href="{{ '/assets/css/categories.css' | relative_url }}" as="style">
18-
<link rel="stylesheet" href="{{ '/assets/css/categories.css' | relative_url }}">
19-
20-
{% elsif page.type == 'tags' %}
21-
22-
<link rel="preload" href="{{ '/assets/css/tags.css' | relative_url }}" as="style">
23-
<link rel="stylesheet" href="{{ '/assets/css/tags.css' | relative_url }}">
24-
25-
{% elsif page.type == 'archives' %}
26-
27-
<link rel="preload" href="{{ '/assets/css/archives.css' | relative_url }}" as="style">
28-
<link rel="stylesheet" href="{{ '/assets/css/archives.css' | relative_url }}">
15+
{% if page.collection == 'tabs' and page.title != 'About' %}
16+
17+
{% if page.title == 'Categories' %}
18+
<link rel="preload" href="{{ '/assets/css/categories.css' | relative_url }}" as="style">
19+
<link rel="stylesheet" href="{{ '/assets/css/categories.css' | relative_url }}">
20+
21+
{% elsif page.title == 'Tags' %}
22+
<link rel="preload" href="{{ '/assets/css/tags.css' | relative_url }}" as="style">
23+
<link rel="stylesheet" href="{{ '/assets/css/tags.css' | relative_url }}">
24+
25+
{% elsif page.title == 'Archives'%}
26+
<link rel="preload" href="{{ '/assets/css/archives.css' | relative_url }}" as="style">
27+
<link rel="stylesheet" href="{{ '/assets/css/archives.css' | relative_url }}">
28+
29+
{% endif %}
2930

3031
{% else %}
3132

_includes/js-selector.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
{% elsif page.layout == 'page' %}
2424

25-
{% if page.type == 'categories' %}
25+
{% if page.title == 'Categories' and page.collection == 'tabs' %}
2626
<script async src="{{ '/assets/js/categories.min.js' | relative_url }}"></script>
2727
{% else %}
2828
<script async src="{{ '/assets/js/page.min.js' | relative_url }}"></script>

_includes/sidebar.html

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-->
88

99
<div id="nav-wrapper">
10+
1011
<div id="profile-wrapper" class="d-flex flex-column">
1112
<div id="avatar" class="d-flex justify-content-center">
1213
<a href="{{ site.baseurl }}/" alt="avatar">
@@ -25,31 +26,25 @@
2526
</div>
2627
<div class="site-subtitle font-italic">{{- site.tagline -}}</div>
2728
</div>
28-
</div>
29+
</div><!-- #profile-wrapper -->
2930

3031
<ul class="nav flex-column">
31-
{% assign page_urls = page.url | split: "/" %}
32-
33-
{% for item in site.data.tabs %}
34-
{% assign ref = site.baseurl | append: "/" %}
35-
36-
{% if item.path %}
37-
{% assign ref = ref | append: item.path | append: "/" %}
38-
{% if item.url %}
39-
{% assign ref = ref | append: item.url | append: "/" %}
40-
{% endif %}
41-
{% endif %}
42-
43-
<li class="nav-item d-flex justify-content-center
44-
{% if item.url == page_urls.last
45-
or item.name == page.tab_active
46-
or item.name == "Home" and page.layout == "home" %}active{% endif %}">
47-
<a href="{{ ref }}" class="nav-link d-flex justify-content-center align-items-center w-100">
48-
<i class="fa-fw {{ item.icon }} ml-xl-3 mr-xl-3 unloaded"></i>
49-
<span>{{ item.name | upcase }}</span>
32+
<!-- home -->
33+
<li class="nav-item d-flex justify-content-center {% if page.layout == 'home' %}active{% endif %}">
34+
<a href="/" class="nav-link d-flex justify-content-center align-items-center w-100">
35+
<i class="fa-fw fas fa-home ml-xl-3 mr-xl-3 unloaded"></i>
36+
<span>{{ "HOME" }}</span>
37+
</a>
38+
</li>
39+
<!-- the real tabs -->
40+
{% for tab in site.tabs %}
41+
<li class="nav-item d-flex justify-content-center {% if tab.url == page.url %}active{% endif %}">
42+
<a href="{{ tab.url }}" class="nav-link d-flex justify-content-center align-items-center w-100">
43+
<i class="fa-fw {{ tab.icon }} ml-xl-3 mr-xl-3 unloaded"></i>
44+
<span>{{ tab.title | upcase }}</span>
5045
</a>
5146
</li> <!-- .nav-item -->
52-
{% endfor %}
47+
{% endfor %}
5348

5449
</ul> <!-- ul.nav.flex-column -->
5550

_includes/topbar.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
<i id="sidebar-trigger" class="fas fa-bars fa-fw"></i>
3030

3131
<div id="topbar-title">
32-
{% if page.location %}
33-
{{- page.location -}}
34-
{% elsif page.layout == "home" %}
35-
{{- site.title -}}
36-
{% else %}
37-
{{- page.title -}}
38-
{% endif %}
32+
{% if page.layout == 'home' %}
33+
{{- site.title -}}
34+
{% elsif page.collection == 'tabs' %}
35+
{{- page.title -}}
36+
{% else %}
37+
{{- page.layout | capitalize -}}
38+
{% endif %}
3939
</div>
4040

4141
<i id="search-trigger" class="fas fa-search fa-fw"></i>
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
title: About
3+
icon: fas fa-info
4+
order: 4
35

46
# The About page
57
# v2.0
@@ -8,4 +10,5 @@ title: About
810
# MIT License
911
---
1012

11-
> **Note**: Add Markdown syntax content to file `tabs/about.md` and it will show up on this page.
13+
14+
> **Note**: Add Markdown syntax content to file `_tabs/about.md` and it will show up on this page.

tabs/archives.md renamed to _tabs/archives.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Archives
3-
type: archives
3+
icon: fas fa-archive
4+
order: 3
5+
46
# The Archives of posts.
57
# v2.0
68
# https://github.com/cotes2020/jekyll-theme-chirpy
@@ -37,4 +39,4 @@ type: archives
3739
{% assign last_month = "" %}
3840
{% endif %}
3941
{% endfor %}
40-
</div>
42+
</div>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Categories
3-
type: categories
3+
icon: fas fa-stream
4+
order: 1
5+
46
# All the Categories of posts
57
# v2.0
68
# https://github.com/cotes2020/jekyll-theme-chirpy

tabs/tags.md renamed to _tabs/tags.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Tags
3-
type: tags
3+
icon: fas fa-tags
4+
order: 2
5+
46
# All the Tags of posts.
57
# v2.0
68
# https://github.com/cotes2020/jekyll-theme-chirpy

0 commit comments

Comments
 (0)