Link to source code of post

Rather than displaying the hash separately, this just makes the date a link
to the source code.  Until I display a modification date, this will also
make it easy to see the history of the file.
master
Mike Gerwitz 2019-01-16 23:59:26 -05:00
parent f38aada781
commit 6d9defe292
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
2 changed files with 17 additions and 2 deletions

View File

@ -29,6 +29,8 @@
# the date, and we want to do all HTML processing now.
##
declare -r srcref=/projects/thoughts/tree
set -euo pipefail
# Pandoc output format and extensions.
@ -59,6 +61,7 @@ pexts()
hgroup-wrap()
{
local -r date=${1?Missing date}
local -r file=${2?Missing file}
# Abort if this is not a date prefix
[[ $date =~ [0-9]{4}-[0-9]{2}-[0-9]{2} ]] || {
@ -66,9 +69,16 @@ hgroup-wrap()
return
}
local -r repo_href="$srcref/$file"
local anchor
printf -vanchor '<a class="muted" href="%s">%s</a>' \
"$repo_href" \
"$date"
sed '/^<h1/{
i<hgroup>
a<h2 class="date">'"$date"'</h2></hgroup>
a<h2 class="date">'"$anchor"'</h2></hgroup>
}'
}
@ -89,7 +99,7 @@ main()
-A src/footer.tpl.htm \
< "$file" \
| src/h12title @__PAGE_TITLE__@ \
| hgroup-wrap "$date"
| hgroup-wrap "$date" "$file"
}

View File

@ -92,6 +92,11 @@ a:visited { color: #6666cc; }
text-decoration: none;
}
a.muted {
color: inherit;
text-decoration: none;
}
a.box {
display: block;