diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-04 17:13:22 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-04 17:13:22 -0500 |
commit | 90e593e800e62b1605a8052a54e0ab3371dd3dde (patch) | |
tree | 35290948b249e6e756a3fdf6724fc8aa2bb4c6af /bin/index | |
parent | 5e257d407b4abf2be61c656dfb1d383396df35b1 (diff) |
implement sections
Diffstat (limited to 'bin/index')
-rwxr-xr-x | bin/index | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -15,7 +15,7 @@ webpath = (@path+'/').sub(/^(src|out)\//, '/') if type == 'atom' webpath += 'index.atom' end -@url = URI::parse('https://www.andrewdm.me') + webpath +@url = URI::parse('https://www.andrewdm.me/') + webpath indexyaml = @path.sub('out', 'src')+'/index.yaml' if File.exists?(indexyaml) @@ -36,4 +36,26 @@ end # main @title = metadata['title'] || @path.sub('out', '') + +def guess_section(page) + for path in @sections.keys do + if @url.route_to(page.url).to_s.start_with?(path+'/') + return path + end + end + return '' +end + +@sections = { '' => {'head' => '', 'body' => []} } +(metadata['sections'] || []).each do |path, name| + @sections[path] = { + 'head' => name, + 'body' => [] + } +end +for page in @pages do + section = page.section || guess_section(page) + @sections[section]['body'].push(page) +end + erb.run() |