summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/index.atom.erb8
-rw-r--r--bin/index.md.erb4
-rw-r--r--bin/page.html.erb2
-rw-r--r--bin/util.rb19
4 files changed, 20 insertions, 13 deletions
diff --git a/bin/index.atom.erb b/bin/index.atom.erb
index 7864e75..0667088 100644
--- a/bin/index.atom.erb
+++ b/bin/index.atom.erb
@@ -5,17 +5,17 @@
<link rel="self" type="application/atom+xml" href="./index.atom"/>
<link rel="alternate" type="text/html" href="./"/>
<link rel="alternate" type="text/markdown" href="./index.md"/>
- <updated><%= @pages.map{|p|p.date}.sort.last.rfc3339 %></updated>
+ <updated><%= @pages.map{|p|p.updated}.sort.last.rfc3339 %></updated>
<author><%= Person.new("Andrew Murrell").atom %></author>
<id>https://lukeshu.com/blog/</id>
- <% @pages.sort_by{|p| p.date}.reverse.each do |page| %>
+ <% @pages.sort_by{|p| p.updated}.reverse.each do |page| %>
<entry xmlns="http://www.w3.org/2005/Atom">
<link rel="alternate" type="text/html" href="./<%= page.slug %>.html"/>
<link rel="alternate" type="text/markdown" href="./<%= page.slug %>.md"/>
<id>https://lukeshu.com/blog/<%= page.slug %>.html</id>
- <updated><%= page.date.rfc3339 %></updated>
- <published><%= page.date.rfc3339 %></published>
+ <updated><%= page.updated.rfc3339 %></updated>
+ <published><%= page.published.rfc3339 %></published>
<title><%= page.title %></title>
<content type="html"><%= html_escape(page.content) %></content>
<author><%= page.author.atom %></author>
diff --git a/bin/index.md.erb b/bin/index.md.erb
index 392447e..a9419ba 100644
--- a/bin/index.md.erb
+++ b/bin/index.md.erb
@@ -2,5 +2,5 @@
title: "<%= @path %>"
---
-<% @pages.sort_by{|a|a.published}.each do |a| %>
- * <time><%= a.published.strftime('%Y-%m-%d') %></time> - [<%= a.title %>](./<%= a.slug %>.html) (last updated <time><%= a.updated.strftime('%Y-%m-%d') %></time>)<% end %>
+<% @pages.sort_by{|a|a.published}.reverse.each do |a| %>
+ * <time><%= a.published.strftime('%Y-%m-%d') %></time> - [<%= a.title %>](<%= a.url %>) (last updated <time><%= a.updated.strftime('%Y-%m-%d') %></time>)<% end %>
diff --git a/bin/page.html.erb b/bin/page.html.erb
index 694d11a..8317282 100644
--- a/bin/page.html.erb
+++ b/bin/page.html.erb
@@ -9,7 +9,7 @@
</head>
<body>
<header>
- <p><%= @page.breadcrumbs %></p>
+ <p class=breadcrumbs><%= @page.breadcrumbs %></p>
<h1>Andrew D. Murrell</h1>
<nav>
<ul>
diff --git a/bin/util.rb b/bin/util.rb
index ec604a3..3ded48e 100644
--- a/bin/util.rb
+++ b/bin/util.rb
@@ -137,16 +137,23 @@ class Page
@src ||= infile.sub(/^(src|out)\//, '/')
end
+ def url
+ if @url.nil?
+ u = src.sub(/\.[^\/.]*$/, '.html').sub(/\/index[.]html$/, '')
+ @url = u == '' ? '/' : u
+ end
+ @url
+ end
+
def breadcrumbs
if @breadcrumbs.nil?
bc = []
- url = src.sub(/\.[^\/.]*$/, '.html').sub(/\/index[.]html$/, '')
- url = '/' if url == ''
- while url != "/"
- bc.unshift("<a href=\"#{url}\">#{File.basename(url, File.extname(url))}</a>")
- url = File.dirname(url)
+ u = url
+ while u != "/"
+ bc.unshift("<a href=\"#{u}\">#{File.basename(u, File.extname(u))}</a>")
+ u = File.dirname(u)
end
- bc.unshift("<a href=\"#{url}\">Andrew D. Murrell</a>")
+ bc.unshift("<a href=\"/\">Andrew D. Murrell</a>")
@breadcrumbs = bc.join(' ยป ')
end
@breadcrumbs