diff --git a/README.md b/README.md index 92ac975..527be47 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ _kewt_ is a minimalist ssg inspired by _[werc](http://werc.cat-v.org/)_ and _[kew](https://github.com/uint23/kew)_ -## [Installation](https://kewt.krzak.org/#installation) +## [Installation](https://kewt.krzak.org/docs/installation) ## Contributing diff --git a/awk/generate_sidebar.awk b/awk/generate_sidebar.awk index 20b575a..8088264 100644 --- a/awk/generate_sidebar.awk +++ b/awk/generate_sidebar.awk @@ -4,6 +4,46 @@ function title_from_name(name) { return name } +function get_title(path, default_title, full_path, line, title, in_fm) { + full_path = src "/" path + if (path !~ /\.md$/) { + full_path = full_path "/index.md" + } + + title = "" + in_fm = 0 + while ((getline line < full_path) > 0) { + if (line ~ /^---[[:space:]]*$/) { + if (in_fm == 0) { + in_fm = 1 + continue + } else { + break + } + } + if (in_fm) { + if (line ~ /^[[:space:]]*title[[:space:]]*=/) { + sub(/^[[:space:]]*title[[:space:]]*=[[:space:]]*/, "", line) + if (line ~ /^".*"$/) { + title = substr(line, 2, length(line) - 2) + } else if (line ~ /^'.*'$/) { + title = substr(line, 2, length(line) - 2) + } else { + title = line + } + break + } + } else { + break + } + } + close(full_path) + + if (title != "") return title + return default_title +} + + function compare_paths(p1, p2, parts1, parts2, n1, n2, i, name1, name2, lname1, lname2, w1, w2) { n1 = split(p1, parts1, "/") n2 = split(p2, parts2, "/") @@ -132,7 +172,7 @@ END { continue } - printf "
  • %s