diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 17:39:05 +0100 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-11-09 17:39:05 +0100 |
| commit | 9d2c650d7cadf57ecef3d5a1d39f5f98e298ec64 (patch) | |
| tree | ed33badc6aa8305a5e6ea688a6a08e532c92d268 /generate-blog | |
| parent | f47491b3a89ba769760bb555ea72f1416cb0cb08 (diff) | |
| download | cacharle.xyz-9d2c650d7cadf57ecef3d5a1d39f5f98e298ec64.tar.gz cacharle.xyz-9d2c650d7cadf57ecef3d5a1d39f5f98e298ec64.tar.bz2 cacharle.xyz-9d2c650d7cadf57ecef3d5a1d39f5f98e298ec64.zip | |
Trying to DRY the html with templatestemplates
Diffstat (limited to 'generate-blog')
| -rwxr-xr-x | generate-blog | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/generate-blog b/generate-blog deleted file mode 100755 index 668bad8..0000000 --- a/generate-blog +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -# Put your articles in a blog_src directory -# Depends on pandoc for markdown to html convertion - -cp -vf index.template.html index.html -rm -vf blog/* - -[ ! -d blog_src ] || [ -z "$(ls blog_src)" ] && exit 1 -mkdir -p blog - -for article_path in blog_src/*.md -do - article_dst_path=$(echo "$article_path" | sed 's/blog_src/blog/' | sed 's/\.md/.html/') - - # Convert markdown article to html - tmp_file=$(mktemp) - pandoc -f markdown -t html < "$article_path" > "$tmp_file" - # Put the blog content in a wrapper template - sed "/<!--BLOG-->/ r $tmp_file" < blog.template.html > "$article_dst_path" - - # Add blog artcle link to the index.html - title=$(grep '^# .*$' -m 1 "$article_path" | cut -c 2-) - [ -z "$title" ] && echo "Article $article_path doesn't have a title" && title=$article_path - sed -i'' "/<!--BLOGINDEX-->/ a\ - <li><a href=\"$article_dst_path\">$title</a></li>" index.html - - echo "Generated article at $article_dst_path" -done - -for util_path in utils/* -do - title=$(basename "$util_path" | tr '_' ' ') - sed -i'' "/<!--UTILSINDEX-->/ a\ - <li><a href=\"$util_path\">$title</a></li>" index.html -done |
