~ecs/ecs.d2evs.net

5636f62ced9cd2f38aae09214a0ea16d4c26d3cd — Eyal Sawady 6 months ago 56221e2
Refactor title extraction
3 files changed, 15 insertions(+), 14 deletions(-)

M _config.sh
M _templates/page.html.w
M index.md.w
M _config.sh => _config.sh +11 -0
@@ 1,3 1,14 @@
get_title() {
	_title="$title"
	file="$(mktemp)"
	# TODO: is this good enough?
	wersh.awk <"$root/posts/$1" | grep -v '^ *emit' >"$file"
	. "$file"
	rm "$file"
	printf "%s" "$title"
	title="$_title"
}

case $input in
	*.md.w)
		preprocessor="markdown -f fencedcode"

M _templates/page.html.w => _templates/page.html.w +1 -6
@@ 12,12 12,7 @@
      <a href="/">Home</a>
      <div class="recent">Recent:</div>
% for i in $(ls "$root/posts" | sort -rn | head -n3); do
%     file="$(mktemp)"
%     # TODO: is this good enough?
%     wersh.awk <"$root/posts/$i" | grep -v '^ *emit' >"$file"
%     . "$file"
%     echo "<a href=\"/posts/${i%\.w}\">$title</a>"
%     rm "$file"
%     echo "<a href=\"/posts/${i%\.w}\">$(get_title "$i")</a>"
% done
    </div>
  </small>

M index.md.w => index.md.w +3 -8
@@ 1,3 1,5 @@
% title="ecs's blog"

# ecs's blog

I do stuff, most of which does not involve writing blog posts.


@@ 6,13 8,6 @@ This site is licensed CC-BY-SA, you can view the code at
<https://git.sr.ht/~ecs/ecs.d2evs.net>.

% for i in $(ls "$root/posts"); do
%     file="$(mktemp)"
%     # TODO: is this good enough?
%     wersh.awk <"$root/posts/$i" | grep -v '^ *emit' >"$file"
%     . "$file"
%     emit "<br>"
%     emit "<a href=\"/posts/${i%\.w}\">$title</a>"
%     rm "$file"
%     emit "<a href=\"/posts/${i%\.w}\">$(get_title "$i")</a>"
% done

% title="ecs's blog"