diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-07-25 12:16:54 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-07-25 12:16:54 +0200 |
| commit | f7a92ef51e97d796f1fc90849d179e502077ee59 (patch) | |
| tree | b05f0a54a71e0143d5a7be241b24726bc75dd99b | |
| parent | 860a213d88e292b972a31a56fc1f573aa3d75f19 (diff) | |
| download | cacharle.xyz-f7a92ef51e97d796f1fc90849d179e502077ee59.tar.gz cacharle.xyz-f7a92ef51e97d796f1fc90849d179e502077ee59.tar.bz2 cacharle.xyz-f7a92ef51e97d796f1fc90849d179e502077ee59.zip | |
Added blog articles generator (from markdown)
| -rw-r--r-- | blog.template.html | 20 | ||||
| -rwxr-xr-x | generate-blog | 29 | ||||
| -rw-r--r-- | index.html | 6 | ||||
| -rw-r--r-- | index.template.html | 28 |
4 files changed, 83 insertions, 0 deletions
diff --git a/blog.template.html b/blog.template.html new file mode 100644 index 0000000..7d47893 --- /dev/null +++ b/blog.template.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> + +<html> + <head> + <title>cacharle</title> + <link rel="stylesheet" type="text/css" href="../style.css"/> + <meta charset="utf-8"/> + <link rel="icon" type="image/png" href="../favicon.png" /> + </head> + + <body> + <div id="page-wrapper"> + <!--BLOG--> + </div> + + <footer> + <!--TODO--> + <footer> + </body> +</html> diff --git a/generate-blog b/generate-blog new file mode 100755 index 0000000..8694b74 --- /dev/null +++ b/generate-blog @@ -0,0 +1,29 @@ +#!/bin/sh + +# Put your articles in a blog_src directory +# Depends on pandoc for markdown to html convertion + +[ ! -d blog_src ] || [ -z $(ls blog_src) ] && exit 1 +mkdir -p blog + +cp -vf index.template.html index.html +rm -vf 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 @@ -16,6 +16,12 @@ <p>This site is an experiment to host some of the services I use every day like a mail server and a <a href="https://git.cacharle.xyz">git server</a> and becoming more independant in general.</p> <p>Inspired by a serie of <a href="https://www.youtube.com/watch?v=bdKZVIGRAKQ&list=PL-p5XmQHB_JRRnoQyjOfioJdDmu87DIJc">videos</a> posted by <a href="https://lukesmith.xyz">Luke Smith</a>.</p> + <h2>Blog articles</h2> + <ul> + <!--BLOGINDEX--> +<li><a href="blog/yo.html"> yo</a></li> + </ul> + <h2>Links</h2> <li><a href="https://github.com/cacharle">github</a></li> <li><a href="https://git.cacharle.xyz">my git server</a></li> diff --git a/index.template.html b/index.template.html new file mode 100644 index 0000000..3e5d33e --- /dev/null +++ b/index.template.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> + +<html> + <head> + <title>cacharle</title> + <link rel="stylesheet" type="text/css" href="style.css"/> + <meta charset="utf-8"/> + <link rel="icon" type="image/png" href="favicon.png" /> + </head> + + <body><div id="page-wrapper"> + <h1>Charles's website</h1> + + <h2>About me</h2> + <p>I'm a computer science student currently at <a href="https://www.s19.be/">s19</a>, a summary of my progress can be found <a href="school.html">here</a></p> + <p>This site is an experiment to host some of the services I use every day like a mail server and a <a href="https://git.cacharle.xyz">git server</a> and becoming more independant in general.</p> + <p>Inspired by a serie of <a href="https://www.youtube.com/watch?v=bdKZVIGRAKQ&list=PL-p5XmQHB_JRRnoQyjOfioJdDmu87DIJc">videos</a> posted by <a href="https://lukesmith.xyz">Luke Smith</a>.</p> + + <h2>Blog articles</h2> + <ul> + <!--BLOGINDEX--> + </ul> + + <h2>Links</h2> + <li><a href="https://github.com/cacharle">github</a></li> + <li><a href="https://git.cacharle.xyz">my git server</a></li> + </div></body> +</html> |
