Skip to content

Commit

Permalink
Add jekyll-toc support
Browse files Browse the repository at this point in the history
Is only applied if "toc: true" is added to post header.

- Update gem deps (required by jekyll-toc)
- Modified post.html to add toc after intro section
  • Loading branch information
amaiorano committed Dec 29, 2023
1 parent a3f7347 commit 59fba21
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
gem 'jekyll-toc'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
Expand All @@ -28,5 +29,4 @@ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?


gem "webrick", "~> 1.7"
145 changes: 69 additions & 76 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,64 +1,54 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.4.7)
activesupport (7.1.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bigdecimal (3.1.5)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.23.9)
concurrent-ruby (1.1.10)
dnsruby (1.61.9)
simpleidn (~> 0.1)
commonmarker (0.23.10)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
dnsruby (1.70.0)
simpleidn (~> 0.2.1)
drb (2.2.0)
ruby2_keywords
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
ethon (0.15.0)
ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
execjs (2.9.1)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.15.5)
ffi (1.15.5-x64-mingw-ucrt)
ffi (1.15.5-x64-unknown)
faraday-net_http (3.0.2)
ffi (1.16.3)
ffi (1.16.3-x64-mingw-ucrt)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (226)
github-pages (228)
github-pages-health-check (= 1.17.9)
jekyll (= 3.9.2)
jekyll (= 3.9.3)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
jekyll-commonmark-ghpages (= 0.2.0)
jekyll-commonmark-ghpages (= 0.4.0)
jekyll-default-layout (= 0.1.4)
jekyll-feed (= 0.15.1)
jekyll-gist (= 1.5.0)
Expand Down Expand Up @@ -92,10 +82,10 @@ GEM
jemoji (= 0.12.0)
kramdown (= 2.3.2)
kramdown-parser-gfm (= 1.1.0)
liquid (= 4.0.3)
liquid (= 4.0.4)
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.13.4, < 2.0)
nokogiri (>= 1.13.6, < 2.0)
rouge (= 3.26.0)
terminal-table (~> 1.4)
github-pages-health-check (1.17.9)
Expand All @@ -104,17 +94,17 @@ GEM
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
typhoeus (~> 1.3)
html-pipeline (2.14.1)
html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
i18n (0.9.5)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jekyll (3.9.2)
jekyll (3.9.3)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 2.0)
kramdown (>= 1.17, < 3)
Expand All @@ -130,11 +120,11 @@ GEM
coffee-script-source (~> 1.11.1)
jekyll-commonmark (1.4.0)
commonmarker (~> 0.22)
jekyll-commonmark-ghpages (0.2.0)
commonmarker (~> 0.23.4)
jekyll-commonmark-ghpages (0.4.0)
commonmarker (~> 0.23.7)
jekyll (~> 3.9.0)
jekyll-commonmark (~> 1.4.0)
rouge (>= 2.0, < 4.0)
rouge (>= 2.0, < 5.0)
jekyll-default-layout (0.1.4)
jekyll (~> 3.0)
jekyll-feed (0.15.1)
Expand Down Expand Up @@ -212,6 +202,9 @@ GEM
jekyll-seo-tag (~> 2.0)
jekyll-titles-from-headings (0.5.3)
jekyll (>= 3.3, < 5.0)
jekyll-toc (0.18.0)
jekyll (>= 3.9)
nokogiri (~> 1.12)
jekyll-watch (2.2.1)
listen (~> 3.0)
jemoji (0.12.0)
Expand All @@ -222,36 +215,36 @@ GEM
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.7.1)
liquid (4.0.4)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
mini_portile2 (2.8.1)
mini_portile2 (2.8.5)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.15.0)
multipart-post (2.1.1)
nokogiri (1.14.3)
mini_portile2 (~> 2.8.0)
minitest (5.20.0)
mutex_m (0.2.0)
nokogiri (1.16.0)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.14.3-x64-mingw-ucrt)
nokogiri (1.16.0-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.14.3-x86_64-linux)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.2)
rb-fsevent (0.11.1)
racc (1.7.3)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rexml (3.2.6)
rouge (3.26.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand All @@ -261,26 +254,24 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sawyer (0.8.2)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
faraday (>= 0.17.3, < 3)
simpleidn (0.2.1)
unf (~> 0.1.4)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
typhoeus (1.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
tzinfo-data (1.2023.3)
tzinfo (>= 1.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.1)
unf_ext (0.0.9.1)
unf_ext (0.0.9.1-x64-mingw-ucrt)
unicode-display_width (1.8.0)
webrick (1.7.0)
zeitwerk (2.5.4)
wdm (0.1.1)
webrick (1.8.1)

PLATFORMS
x64-mingw-ucrt
Expand All @@ -290,8 +281,10 @@ PLATFORMS
DEPENDENCIES
github-pages
jekyll-feed (~> 0.6)
jekyll-toc
minima (~> 2.0)
tzinfo-data
wdm (~> 0.1.0)
webrick (~> 1.7)

BUNDLED WITH
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ markdown: kramdown
theme: minima
plugins:
- jekyll-feed
- jekyll-toc

show_excerpts: true
google_analytics: UA-NNNNNNNN-N
Expand Down
17 changes: 15 additions & 2 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<!-- Overrides the Minima theme's default post layout to inject header -->
<!-- anchors from https://github.com/allejo/jekyll-anchor-headings -->
<article class="post h-entry" itemscope itemtype="http://schema.org/BlogPosting">

<header class="post-header">
<h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}</h1>
<p class="post-meta">
Expand All @@ -18,7 +17,21 @@ <h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}
</header>

<div class="post-content e-content" itemprop="articleBody">
{% include anchor_headings.html html=content anchorBody="#" %}
<!-- Extract the intro text from the rest by splitting on the first header '<h' tag. -->
<!-- We use this to emit the intro, then the TOC, then the rest -->
{% assign intro = content | split: '<h' | first %}
{% capture rest %} {{content|remove: intro}} {% endcapture %}

<div id="markdown-content">
{{ intro }}
</div>
<div id="table-of-contents">
{% toc %}
</div>
<div id="markdown-content">
<!-- use anchor_headings to add anchors to each header -->
{% include anchor_headings.html html=rest anchorBody="#" %}
</div>
</div>

{%- if site.disqus.shortname -%}
Expand Down
9 changes: 9 additions & 0 deletions assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@
overflow: hidden;
padding: 2%;
min-height: 1px;
}

.section-nav
{
background-color: #fff;
margin: 5px 0;
padding: 10px 30px;
border: 1px solid #e8e8e8;
border-radius: 3px;
}

0 comments on commit 59fba21

Please sign in to comment.