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: redirect_from:
- /norobots/ - /norobots/
- /assets/ - /assets/
- /tabs/
- /categories/
- /tags/
- /posts/ - /posts/
dynamic_title: true dynamic_title: true
@ -16,5 +13,9 @@ dynamic_title: true
<div class="lead"> <div class="lead">
<p>Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. </p> <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> </div>

View file

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

View file

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