site

My personal website.

Date: Sun, 15 Aug 2021 16:58:20 +0200

Add titles to generated html pages

Diffstat:

M generate                            |       5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)

@@ -12,7 +12,7 @@ program="$(printf "%s" '
 BEGIN {
     html = --HTML--;
     if (html)
-        print "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\" />\n<link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\" />\n<link rel=\"stylesheet\" href=\"/style.css\" type=\"text/css\" />\n</head>\n<body>";
+        print "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<title>--TITLE--</title>\n<meta charset=\"utf-8\" />\n<link rel=\"icon\" href=\"favicon.ico\" type=\"image/x-icon\" />\n<link rel=\"stylesheet\" href=\"/style.css\" type=\"text/css\" />\n</head>\n<body>";
 }
 END {
     if (html)
@@ -211,7 +211,8 @@ cp -rf ./* "$dir"
 files="$(find "$dir" -name '*.gmi' -type f)"
 
 while read -r file <&4; do
-    awk "$program" "$file" > "$(printf "%s" "$file" | sed "s/\.gmi$/.$extension/")"
+    title="$(grep "^# " "$file" | cut -c 3-)"
+    awk "$(printf "%s" "$program" | sed "s|--TITLE--|$title|")" "$file" > "$(printf "%s" "$file" | sed "s/\.gmi$/.$extension/")"
 done 4<< EOF
 $files
 EOF