aboutsummaryrefslogtreecommitdiff
path: root/gen.sh
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-06-27 01:04:51 +0200
committerJoris Guyonvarch2015-06-27 01:04:51 +0200
commit6ec9a6fc1d43c8d2a1495e147157dc545175b129 (patch)
tree9e9809a02c937e6a95eb9c63890a945a250ffa11 /gen.sh
parentb590ca0aea8bbae34885e98b59bc465c09400ca3 (diff)
Generate static pages with a watcher and serve files with a simple http server
Diffstat (limited to 'gen.sh')
-rwxr-xr-xgen.sh31
1 files changed, 21 insertions, 10 deletions
diff --git a/gen.sh b/gen.sh
index 9fbf044..6d5f3c7 100755
--- a/gen.sh
+++ b/gen.sh
@@ -1,24 +1,35 @@
#!/bin/bash
-
-MARKDOWN_DIR="Pages"
+MARKDOWN_DIR="Markdown"
MARKDOWN_DIR_LENGTH=$(expr 1 + ${#MARKDOWN_DIR})
+HTML_DIR="Page"
-HTML_DIR="Html"
+# clean_html_files: IO ()
+clean_html_files () {
+ rm -rf "$HTML_DIR"
+}
+# write_html_file: FilePath -> FilePath -> IO ()
+write_html_file () {
+ mkdir -p $(dirname "$2")
+ cat Fragments/begin.html > "$2"
+ pandoc -t html "$1" >> "$2"
+ cat Fragments/end.html >> "$2"
+}
+echo ""
+echo "> Generating HTML files…"
+clean_html_files
-SELECTOR="${MARKDOWN_DIR}/**/*.md"
+SELECTOR="${MARKDOWN_DIR}/*.md ${MARKDOWN_DIR}/**/*.md"
for FILENAME in $SELECTOR; do
WITHOUT_DIR=${FILENAME:$MARKDOWN_DIR_LENGTH}
WITHOUT_EXT=${WITHOUT_DIR%.*}
HTML_FILENAME="$HTML_DIR/$WITHOUT_EXT.html"
- # echo $FILENAME
- # echo $HTML_FILENAME
-
- # echo "pandoc -o $HTML_FILENAME $FILENAME"
- # pandoc -o "\"$HTML_FILENAME\"" "\"$FILENAME\""
+ write_html_file "$FILENAME" "$HTML_FILENAME"
done
-pandoc -o Html/accessoires/eponges.html Pages/accessoires/eponges.md
+write_html_file "$MARKDOWN_DIR/Index.md" index.html
+
+echo "> Done !"