aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-05 10:28:12 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-05 10:28:12 +0200
commit1643801e434c2c9bb09353998856210a46056f3b (patch)
treee83738f8a874e218f5f1bcbed250f9ecf6ab82dd
parenta041f469ff41f53601c97454b41cfc4ef3f3ed45 (diff)
update permalinks + fix indents
-rw-r--r--.editorconfig11
-rw-r--r--_config.yml3
-rw-r--r--_plugins/tag-color.rb16
-rw-r--r--_plugins/toc.rb110
4 files changed, 76 insertions, 64 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..1bd7da9
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,11 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+insert_final_newline = true
+
+[*.{md,yml}]
+indent_style = space
+indent_size = 2
+
diff --git a/_config.yml b/_config.yml
index 62b2631..4f986b7 100644
--- a/_config.yml
+++ b/_config.yml
@@ -1,7 +1,7 @@
title: "Loek's Blog"
rss:
url: https://blog.pipeframe.xyz/atom.xml
-permalink: /post/:title
+permalink: /post/:title/
exclude:
- makefile
- license
@@ -18,3 +18,4 @@ sass:
sourcemap: development
gems:
- jekyll-liquify
+
diff --git a/_plugins/tag-color.rb b/_plugins/tag-color.rb
index 3927abf..9f119fb 100644
--- a/_plugins/tag-color.rb
+++ b/_plugins/tag-color.rb
@@ -1,12 +1,12 @@
module TagColor
- def to_tag_color(str)
- sum = 0
- str.chars.each do |i|
- sum += ?i.ord
- sum %= 360
- end
- sum
- end
+ def to_tag_color(str)
+ sum = 0
+ str.chars.each do |i|
+ sum += ?i.ord
+ sum %= 360
+ end
+ sum
+ end
end
Liquid::Template.register_filter(TagColor)
diff --git a/_plugins/toc.rb b/_plugins/toc.rb
index 216341d..3c4f836 100644
--- a/_plugins/toc.rb
+++ b/_plugins/toc.rb
@@ -1,61 +1,61 @@
require 'nokogiri'
module Jekyll
- class TOC < Liquid::Tag
- def render context
- # load HTML into nokogiri
- html = context.registers[:page]['content']
- doc = Nokogiri::HTML(html)
-
- # enumerate over all h1-4 headings
- @els = doc.css("h1, h2, h3, h4")
- return '<div class="chapterChildren">%s</div>' % [ output_toc ]
- end
-
- def output_toc
- # empty toc (this check prevents crash)
- return "" if @els.length == 0
-
- output = '<ul>'
-
- current_level = el_level(@els[0])
-
- while @els.length > 0
- el = @els[0]
- el_next = @els[1]
- level = el_level(el)
- level_next = el_level(el_next || el) # || el to prevent crash on end of list
-
- if level >= level_next
- output += '<li>'
- else
- output += '<li class="stub"><details open>'
- output += '<summary>'
- end
-
- output += '<a href="#%s">%s</a>' % [ el['id'], el.inner_html ]
- @els.shift()
-
- if level >= level_next
- output += '</li>'
- else
- output += '</summary>'
- output += output_toc
- output += '</details></li>'
- end
-
- break if level_next < level
- end
-
- output += '</ul>'
-
- return output
- end
-
- def el_level el
- return Integer(el.name[1..])
- end
- end
+ class TOC < Liquid::Tag
+ def render context
+ # load HTML into nokogiri
+ html = context.registers[:page]['content']
+ doc = Nokogiri::HTML(html)
+
+ # enumerate over all h1-4 headings
+ @els = doc.css("h1, h2, h3, h4")
+ return '<div class="chapterChildren">%s</div>' % [ output_toc ]
+ end
+
+ def output_toc
+ # empty toc (this check prevents crash)
+ return "" if @els.length == 0
+
+ output = '<ul>'
+
+ current_level = el_level(@els[0])
+
+ while @els.length > 0
+ el = @els[0]
+ el_next = @els[1]
+ level = el_level(el)
+ level_next = el_level(el_next || el) # || el to prevent crash on end of list
+
+ if level >= level_next
+ output += '<li>'
+ else
+ output += '<li class="stub"><details open>'
+ output += '<summary>'
+ end
+
+ output += '<a href="#%s">%s</a>' % [ el['id'], el.inner_html ]
+ @els.shift()
+
+ if level >= level_next
+ output += '</li>'
+ else
+ output += '</summary>'
+ output += output_toc
+ output += '</details></li>'
+ end
+
+ break if level_next < level
+ end
+
+ output += '</ul>'
+
+ return output
+ end
+
+ def el_level el
+ return Integer(el.name[1..])
+ end
+ end
end
Liquid::Template.register_tag('toc', Jekyll::TOC)