Skip to content

Commit 95d3ac7

Browse files
committed
Add breadcrumbs, giscus, reading time & UI
Introduce breadcrumbs, Giscus-based comments, and a reading-time include; wire them into layouts (default, post, page, home, archive, tags) and add styles. Upgrade Jekyll and related gems, adjust gemspec/Gemfile and add .bundle config for Windows builds. Add code-copy buttons (JS + syntax styles), theme-toggle animation, and defensive event handling. Add example post and documentation (Giscus setup, todos, Windows setup) and assorted Sass tweaks for categories, comments, and UI refinements.
1 parent 21f4019 commit 95d3ac7

26 files changed

Lines changed: 961 additions & 50 deletions

.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
BUNDLE_BUILD__WDM: "-- --with-cflags=-Wno-implicit-function-declaration"

Gemfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "https://rubygems.org"
88
#
99
# This will help ensure the proper Jekyll version is running.
1010
# Happy Jekylling!
11-
gem "jekyll", "~> 4.1.0"
11+
gem "jekyll", "~> 4.3.4"
1212

1313
# This is the default theme for new Jekyll sites. You may change this to anything you like.
1414

@@ -18,16 +18,23 @@ gem "jekyll", "~> 4.1.0"
1818

1919
# If you have any plugins, put them here!
2020
group :jekyll_plugins do
21-
gem 'jekyll-feed', '~> 0.13'
21+
gem 'jekyll-feed', '~> 0.17'
2222
gem 'jekyll-sitemap', '~> 1.4'
23-
gem 'jekyll-compose', '~> 0.12.0'
23+
gem 'jekyll-compose', '~> 0.12'
2424
gem 'jekyll-postfiles', '~> 3.1'
2525
end
2626

27+
gem "jekyll-sass-converter", "~> 2.2.0"
28+
gem "sassc", "~> 2.4"
29+
30+
gem "csv"
31+
gem "base64"
32+
gem "bigdecimal"
33+
2734
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
2835
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
2936

3037
# Performance-booster for watching directories on Windows
31-
gem "wdm", "~> 0.1.0" if Gem.win_platform?
38+
# gem "wdm", "~> 0.1.0" if Gem.win_platform?
3239

33-
gem "webrick", "~> 1.7"
40+
gem "webrick", "~> 1.9"

_config.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ image: assets/img/ogp.png # This image used for Open Graph more info https://ogp
88
repo: https://github.com/piharpi/jekyll-klise # site repo [optional]
99
mode: dark # default theme "dark" | "light"
1010

11+
# Comments
12+
giscus:
13+
repo: riffpointer/riffpointer.github.io
14+
repo_id: R_kgDORtuMVg
15+
category: Giscus Comments
16+
category_id: DIC_kwDORtuMVs4C9B22
17+
mapping: og:title
18+
strict: 0
19+
reactions_enabled: 1
20+
emit_metadata: 0
21+
input_position: bottom
22+
theme: preferred_color_scheme # follows the visitor's system/theme preference
23+
lang: en
24+
loading: lazy
25+
1126
# Profile settings
1227
author:
1328
name: RiffPointer # author name
@@ -42,9 +57,15 @@ kramdown:
4257
defaults:
4358
- scope:
4459
path: ""
60+
type: posts
4561
values:
4662
layout: post
47-
comments: false
63+
comments: true
64+
- scope:
65+
path: ""
66+
type: pages
67+
values:
68+
comments: true
4869

4970
# Jekyll Compose default front matter
5071
jekyll_compose:
@@ -59,6 +80,7 @@ jekyll_compose:
5980

6081
# Homepage limit posts
6182
number_of_posts: 5
83+
reading_time_words_per_minute: 200
6284

6385
# Build settings
6486
# theme: klise

_includes/breadcrumbs.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{%- unless page.url == "/" -%}
2+
{%- assign crumbs = page.url | remove_first: "/" | split: "/" -%}
3+
{%- assign crumb_url = "" -%}
4+
<nav class="breadcrumbs" aria-label="Breadcrumb">
5+
<a href="/">Home</a>
6+
{%- for crumb in crumbs -%}
7+
{%- unless crumb == "" -%}
8+
{%- assign crumb_url = crumb_url | append: "/" | append: crumb -%}
9+
<span class="breadcrumb-separator" aria-hidden="true">/</span>
10+
{%- if forloop.last -%}
11+
{%- if page.title -%}
12+
<span aria-current="page">{{ page.title | escape }}</span>
13+
{%- else -%}
14+
<span aria-current="page">{{ crumb | replace: "-", " " | capitalize }}</span>
15+
{%- endif -%}
16+
{%- else -%}
17+
<a href="{{ crumb_url }}/">{{ crumb | replace: "-", " " | capitalize }}</a>
18+
{%- endif -%}
19+
{%- endunless -%}
20+
{%- endfor -%}
21+
</nav>
22+
{%- endunless -%}

_includes/comments.html

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,51 @@
1-
<!-- unnecessary file, however you can still use for comment section, e.g disqus -->
2-
<script
3-
src="https://utteranc.es/client.js"
4-
repo="username/reponame"
5-
issue-term="pathname"
6-
label="✨ comment ✨"
7-
theme="github-light"
8-
crossorigin="anonymous"
9-
async
10-
></script>
1+
{% assign giscus_repo = site.giscus.repo | strip %}
2+
{% assign giscus_repo_id = site.giscus.repo_id | strip %}
3+
{% assign giscus_category = site.giscus.category | strip %}
4+
{% assign giscus_category_id = site.giscus.category_id | strip %}
5+
6+
{% assign giscus_configured = false %}
7+
{% if giscus_repo != empty and giscus_repo_id != empty and giscus_category != empty and giscus_category_id != empty %}
8+
{% assign giscus_configured = true %}
9+
{% endif %}
10+
11+
{% assign missing_giscus_fields = "" | split: "," %}
12+
{% if giscus_repo == empty %}
13+
{% assign missing_giscus_fields = missing_giscus_fields | push: "repo" %}
14+
{% endif %}
15+
{% if giscus_repo_id == empty %}
16+
{% assign missing_giscus_fields = missing_giscus_fields | push: "repo_id" %}
17+
{% endif %}
18+
{% if giscus_category == empty %}
19+
{% assign missing_giscus_fields = missing_giscus_fields | push: "category" %}
20+
{% endif %}
21+
{% if giscus_category_id == empty %}
22+
{% assign missing_giscus_fields = missing_giscus_fields | push: "category_id" %}
23+
{% endif %}
24+
25+
<section class="comments">
26+
{% if giscus_configured %}
27+
<div class="giscus"></div>
28+
<script src="https://giscus.app/client.js"
29+
data-repo="{{ giscus_repo }}"
30+
data-repo-id="{{ giscus_repo_id }}"
31+
data-category="{{ giscus_category }}"
32+
data-category-id="{{ giscus_category_id }}"
33+
data-mapping="{{ site.giscus.mapping | default: 'pathname' }}"
34+
data-strict="{{ site.giscus.strict | default: 0 }}"
35+
data-reactions-enabled="{{ site.giscus.reactions_enabled | default: 1 }}"
36+
data-emit-metadata="{{ site.giscus.emit_metadata | default: 0 }}"
37+
data-input-position="{{ site.giscus.input_position | default: 'bottom' }}"
38+
data-theme="{{ site.giscus.theme | default: 'preferred_color_scheme' }}"
39+
data-lang="{{ site.giscus.lang | default: site.lang | default: 'en' }}"
40+
data-loading="{{ site.giscus.loading | default: 'lazy' }}"
41+
crossorigin="anonymous"
42+
async>
43+
</script>
44+
{% else %}
45+
<div class="comments-warning" role="alert" aria-live="polite">
46+
<strong>Comments are unavailable.</strong>
47+
Configure Giscus in <code>_config.yml</code>. Missing field{% if missing_giscus_fields.size != 1 %}s{% endif %}:
48+
<code>{{ missing_giscus_fields | join: ", " }}</code>
49+
</div>
50+
{% endif %}
51+
</section>

_includes/header.html

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<meta name="apple-mobile-web-app-status-bar-style" content="#fff" />
99
<meta name="apple-mobile-web-app-title" content="{{ site.title }}" />
1010
<title>
11-
{% if page.title %}{{ page.title | escape }} - {{ site.title }}{% else %}{{
12-
site.title | escape }}{% endif %}
11+
{% if page.title %}{{ page.title }} - {{ site.title }}{% else %}{{
12+
site.title }}{% endif %}
1313
</title>
1414
<link
1515
rel="alternate"
@@ -58,15 +58,11 @@
5858
<meta property="fb:app_id" content="{{ site.fb_appid }}" />
5959
<meta
6060
property="og:site_name"
61-
content="{% if page.title %}{{ page.title | escape }} | {{
62-
site.author.name
63-
}}{% else %}{{ site.title | escape }}{% endif %}"
61+
content="{{ site.title }}"
6462
/>
6563
<meta
6664
property="og:title"
67-
content="{% if page.title %}{{ page.title | escape }} | {{
68-
site.author.name
69-
}}{% else %}{{ site.title | escape }}{% endif %}"
65+
content="{% if page.title %}{% if page.layout == 'post' %}Post{% else %}Page{% endif %} - {{ page.title }}{% else %}{{ site.title }}{% endif %}"
7066
/>
7167
{% if page.location %}
7268
<meta property="og:type" content="article" />
@@ -104,9 +100,7 @@
104100
<meta name="twitter:card" content="summary" />
105101
<meta
106102
name="twitter:title"
107-
content="{% if page.title %}{{ page.title | escape }} | {{
108-
site.author.twitter
109-
}}{% else %}{{ site.title | escape }}{% endif %}"
103+
content="{{ page.title | default: site.title }}"
110104
/>
111105
<meta
112106
name="twitter:url"

_includes/reading_time.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{%- assign words_per_minute = site.reading_time_words_per_minute | default: 200 -%}
2+
{%- assign text = include.content | strip_html -%}
3+
{%- assign words = text | number_of_words -%}
4+
{%- assign characters = text | size -%}
5+
{%- assign minutes = words | divided_by: words_per_minute -%}
6+
{%- assign remainder = words | modulo: words_per_minute -%}
7+
{%- if remainder > 0 -%}
8+
{%- assign minutes = minutes | plus: 1 -%}
9+
{%- endif -%}
10+
{%- if minutes < 1 -%}
11+
{%- assign minutes = 1 -%}
12+
{%- endif -%}
13+
<span class="{{ include.class | default: 'reading-time' }}" title="{{ words }} words, {{ characters }} characters" aria-label="{{ minutes }} min read, {{ words }} words, {{ characters }} characters">{{ minutes }} min read</span>

_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
{% include navbar.html %}
3030
<div class="wrapper">
31+
{% include breadcrumbs.html %}
3132
{% include author.html %}
3233
<main aria-label="Content">
3334
{{ content }}

_layouts/home.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ <h3 class="posts-item-note" aria-label="Recent Posts">Recent Posts</h3>
1010
<h4 class="post-item-title">
1111
<a href="{{ post.url }}">{{ post.title | escape }}</a>
1212
</h4>
13+
{% include reading_time.html content=post.content class="post-item-reading-time" %}
1314
</article>
1415
{%- endfor -%}

_layouts/page.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@
3030

3131
{% include navbar.html %}
3232
<div class="wrapper">
33+
{% include breadcrumbs.html %}
3334
<header class="header">
3435
<h1 class="header-title center" itemprop="headline">{{ page.title | escape }}.</h1>
3536
</header>
3637
<main class="page-content" aria-label="Content">
3738
{% include anchor_headings.html html=content anchorClass="anchor-head" beforeHeading=true h_min=4 h_max=4 %}
3839
</main>
40+
{% if page.comments != false %}
41+
{% include comments.html %}
42+
{% endif %}
3943
{% include footer.html %}
4044
</div>
4145
</body>

0 commit comments

Comments
 (0)