summaryrefslogtreecommitdiff
path: root/bin/index
diff options
context:
space:
mode:
Diffstat (limited to 'bin/index')
-rwxr-xr-xbin/index24
1 files changed, 23 insertions, 1 deletions
diff --git a/bin/index b/bin/index
index 48968a3..c04618d 100755
--- a/bin/index
+++ b/bin/index
@@ -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()