Generate the breadcrumb by Liquid

also subtracted '/tabs/' from the tabs path
This commit is contained in:
Cotes Chung 2021-01-31 21:43:23 +08:00
parent 1879b94f3d
commit 413a86277b
3 changed files with 40 additions and 52 deletions

View file

@ -6,9 +6,6 @@ permalink: /404.html
redirect_from:
- /norobots/
- /assets/
- /tabs/
- /categories/
- /tags/
- /posts/
dynamic_title: true
@ -16,5 +13,9 @@ dynamic_title: true
<div class="lead">
<p>Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. </p>
<p><a href="{{ site.baseurl }}/">Head back Home</a> to try finding it again, or search for it on the <a href="{{ site.baseurl }}/tabs/archives">Archives page</a>.</p>
<p>
<a href="{{ '/' | relative_url }}">Head back Home</a>
to try finding it again, or search for it on the
<a href="{{ 'archives' | relative_url }}">Archives page</a>.
</p>
</div>

View file

@ -69,7 +69,6 @@ disqus:
# Available options:
#
# light - Use the light color scheme
#
# dark - Use the dark color scheme
#
theme_mode: # [light|dark]
@ -89,6 +88,9 @@ toc: true
paginate: 10
# ------------ The following options are not recommended to be modified ------------------
kramdown:
syntax_highlighter: rouge
syntax_highlighter_opts: # Rouge Options https://github.com/jneen/rouge#full-options
@ -101,7 +103,7 @@ kramdown:
start_line: 1
# DO NOT change this unless you're a Pro user on Jekyll and Web development,
# or you think you're smart enough to change other relevant URLs within this template.
# Or you think you're smart enough to change other relevant URLs within this template.
permalink: /posts/:title/
collections:
@ -119,55 +121,19 @@ defaults:
layout: post
comments: true # Enable comments in posts.
toc: true # Display TOC column in posts.
breadcrumb:
-
label: Posts
url: /
-
scope:
path: _drafts
values:
comments: false
-
scope:
path: index.html
values:
breadcrumb:
-
label: Posts
-
scope:
path: tags
values:
breadcrumb:
-
label: Home
url: /
-
label: Tags
url: /tabs/tags/
-
scope:
path: categories
values:
breadcrumb:
-
label: Home
url: /
-
label: Categories
url: /tabs/categories/
-
scope:
path: ''
type: tabs # see `site.collections`
values:
layout: page
permalink: /:title/
dynamic_title: true # Hide title in mobile screens.
breadcrumb:
-
label: Home
url: /
sass:
style: compressed

View file

@ -5,21 +5,42 @@
<div id="topbar-wrapper" class="row justify-content-center topbar-down">
<div id="topbar" class="col-11 d-flex h-100 align-items-center justify-content-between">
<span id="breadcrumb">
{% for item in page.breadcrumb %}
{% if item.url %}
{% assign paths = page.url | split: '/' %}
{% if paths.size == 0 %}
<!-- index page -->
<span>{{ 'Posts' }}</span>
{% else %}
{% for item in paths %}
{% if forloop.first %}
{% unless page.layout == 'post' %}
<span>
<a href="{{ '/' | relative_url }}">{{ 'Home' }}</a>
</span>
{% endunless %}
{% elsif forloop.last %}
<span>{{ page.title }}</span>
{% else %}
<span>
<a href="{{ site.baseurl }}{{ item.url | remove: '.html'}}">
{{ item.label }}
{% assign url = item %}
{% if item == 'posts' and page.layout == 'post' %}
{% assign url = '/' %}
{% endif %}
<a href="{{ url | relative_url }}">
{{ item | capitalize }}
</a>
</span>
{% else %}
<span>{{ item.label }}</span>
{% endif %}
{% endfor %}
{% unless page.layout == "home" %}
<span>{{ page.title }}</span>
{% endunless %}
{% endif %}
</span><!-- endof #breadcrumb -->