From 270d3ba4990c8ff7ac538d6301574eaac6be86b0 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 22 Nov 2020 04:24:09 +0800 Subject: [PATCH] Use `collections` to improve the tabs --- _config.yml | 22 +++++++++++---------- _data/tabs.yml | 30 ---------------------------- _includes/css-selector.html | 27 +++++++++++++------------ _includes/js-selector.html | 2 +- _includes/sidebar.html | 37 +++++++++++++++-------------------- _includes/topbar.html | 14 ++++++------- {tabs => _tabs}/about.md | 5 ++++- {tabs => _tabs}/archives.md | 6 ++++-- {tabs => _tabs}/categories.md | 4 +++- {tabs => _tabs}/tags.md | 4 +++- assets/css/_addon/main.scss | 2 +- 11 files changed, 65 insertions(+), 88 deletions(-) delete mode 100644 _data/tabs.yml rename {tabs => _tabs}/about.md (52%) rename {tabs => _tabs}/archives.md (96%) rename {tabs => _tabs}/categories.md (99%) rename {tabs => _tabs}/tags.md (96%) diff --git a/_config.yml b/_config.yml index b18e3fd..5be97ee 100644 --- a/_config.yml +++ b/_config.yml @@ -17,8 +17,8 @@ description: >- # used by seo meta and the atom feed bootstrap Jekyll theme with responsive web design and focuses on text presentation. -# Replace with the website url, e.g. 'https://username.github.io' -url: 'protocol://domain' +# fill in the base hostname & protocol for your site, e.g., 'https://username.github.io' +url: '' author: your_full_name # change to your full name @@ -80,7 +80,7 @@ disqus: # theme_mode: dual -# boolean type, global switch for ToC in posts. +# boolean type, the global switch for ToC in posts. toc: true paginate: 10 @@ -105,16 +105,21 @@ kramdown: # or you think you're smart enough to change other relevant URLs within this template. permalink: /posts/:title/ +collections: + tabs: + output: true + sort_by: order + + defaults: - scope: - path: "" # An empty string here means all files in the project + path: '' # An empty string here means all files in the project type: posts values: layout: post comments: true # Enable comments in posts. toc: true # Display TOC column in posts. - location: Post breadcrumb: - label: Posts @@ -128,8 +133,6 @@ defaults: scope: path: tags values: - tab_active: Tags - location: Tag breadcrumb: - label: Home @@ -141,8 +144,6 @@ defaults: scope: path: categories values: - tab_active: Categories - location: Category breadcrumb: - label: Home @@ -152,7 +153,8 @@ defaults: url: /tabs/categories/ - scope: - path: tabs + path: '' + type: tabs # see `site.collections` values: layout: page dynamic_title: true # Hide title in mobile screens. diff --git a/_data/tabs.yml b/_data/tabs.yml deleted file mode 100644 index 0f65841..0000000 --- a/_data/tabs.yml +++ /dev/null @@ -1,30 +0,0 @@ -# The tab data. -# v2.1 -# https://github.com/cotes2020/jekyll-theme-chirpy -# © 2020 Cotes Chung -# MIT Licensed - - -- - name: Home - icon: "fas fa-home" -- - name: Categories - icon: "fas fa-stream" - path: tabs - url: categories -- - name: "Tags" - icon: "fas fa-tags" - path: tabs - url: tags -- - name: "Archives" - path: tabs - url: archives - icon: "fas fa-archive" -- - name: "About" - icon: "fas fa-info" - path: tabs - url: about \ No newline at end of file diff --git a/_includes/css-selector.html b/_includes/css-selector.html index 53e53db..965071b 100644 --- a/_includes/css-selector.html +++ b/_includes/css-selector.html @@ -12,20 +12,21 @@ {% elsif page.layout == 'page' %} - {% if page.type == 'categories' %} + {% if page.collection == 'tabs' and page.title != 'About' %} - - - - {% elsif page.type == 'tags' %} - - - - - {% elsif page.type == 'archives' %} - - - + {% if page.title == 'Categories' %} + + + + {% elsif page.title == 'Tags' %} + + + + {% elsif page.title == 'Archives'%} + + + + {% endif %} {% else %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 62a36e6..622de8f 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -22,7 +22,7 @@ {% elsif page.layout == 'page' %} - {% if page.type == 'categories' %} + {% if page.title == 'Categories' and page.collection == 'tabs' %} {% else %} diff --git a/_includes/sidebar.html b/_includes/sidebar.html index 1e9e4a1..d21702d 100644 --- a/_includes/sidebar.html +++ b/_includes/sidebar.html @@ -7,6 +7,7 @@ --> + diff --git a/_includes/topbar.html b/_includes/topbar.html index 1d4f144..901d2e5 100644 --- a/_includes/topbar.html +++ b/_includes/topbar.html @@ -29,13 +29,13 @@
- {% if page.location %} - {{- page.location -}} - {% elsif page.layout == "home" %} - {{- site.title -}} - {% else %} - {{- page.title -}} - {% endif %} + {% if page.layout == 'home' %} + {{- site.title -}} + {% elsif page.collection == 'tabs' %} + {{- page.title -}} + {% else %} + {{- page.layout | capitalize -}} + {% endif %}
diff --git a/tabs/about.md b/_tabs/about.md similarity index 52% rename from tabs/about.md rename to _tabs/about.md index 8339fbd..a0b1e3e 100644 --- a/tabs/about.md +++ b/_tabs/about.md @@ -1,5 +1,7 @@ --- title: About +icon: fas fa-info +order: 4 # The About page # v2.0 @@ -8,4 +10,5 @@ title: About # MIT License --- -> **Note**: Add Markdown syntax content to file `tabs/about.md` and it will show up on this page. \ No newline at end of file + +> **Note**: Add Markdown syntax content to file `_tabs/about.md` and it will show up on this page. diff --git a/tabs/archives.md b/_tabs/archives.md similarity index 96% rename from tabs/archives.md rename to _tabs/archives.md index e4d4348..e84cc1d 100644 --- a/tabs/archives.md +++ b/_tabs/archives.md @@ -1,6 +1,8 @@ --- title: Archives -type: archives +icon: fas fa-archive +order: 3 + # The Archives of posts. # v2.0 # https://github.com/cotes2020/jekyll-theme-chirpy @@ -37,4 +39,4 @@ type: archives {% assign last_month = "" %} {% endif %} {% endfor %} - \ No newline at end of file + diff --git a/tabs/categories.md b/_tabs/categories.md similarity index 99% rename from tabs/categories.md rename to _tabs/categories.md index 4287e34..e1c7afc 100644 --- a/tabs/categories.md +++ b/_tabs/categories.md @@ -1,6 +1,8 @@ --- title: Categories -type: categories +icon: fas fa-stream +order: 1 + # All the Categories of posts # v2.0 # https://github.com/cotes2020/jekyll-theme-chirpy diff --git a/tabs/tags.md b/_tabs/tags.md similarity index 96% rename from tabs/tags.md rename to _tabs/tags.md index 6a2152a..c676761 100644 --- a/tabs/tags.md +++ b/_tabs/tags.md @@ -1,6 +1,8 @@ --- title: Tags -type: tags +icon: fas fa-tags +order: 2 + # All the Tags of posts. # v2.0 # https://github.com/cotes2020/jekyll-theme-chirpy diff --git a/assets/css/_addon/main.scss b/assets/css/_addon/main.scss index 1dc79ea..d4c09e9 100644 --- a/assets/css/_addon/main.scss +++ b/assets/css/_addon/main.scss @@ -64,7 +64,7 @@ body { /*--- sidebar layout ---*/ -$tab-count: {{ site.data.tabs | size }}; +$tab-count: {{ site.tabs | size | plus: 1 }}; // plus 1 for home tab $sidebar-display: "sidebar-display";