diff --git a/make_site.bash b/make_site.bash index 024fb38..4d9cfef 100755 --- a/make_site.bash +++ b/make_site.bash @@ -17,6 +17,7 @@ OUTPUT_DIR=~/public_html pushd ~ +# Recursively iterate over directories, calling process_file on .md files traverse_dir() { local dir=$1 for d in $dir; do @@ -26,13 +27,40 @@ traverse_dir() { traverse_dir "$d/*" elif [[ $d == *.md ]]; then OUTPUT=${OUTPUT%.md}.html - OUTPUT=${OUTPUT// /_} - echo $OUTPUT - pandoc -f markdown -t html -o $OUTPUT "$d" + #OUTPUT=${OUTPUT// /_} + process_file "$d" "$OUTPUT" fi done } +# Take a Markdown file and process it to HTML +process_file() { + local INPUT=$1 + local OUTPUT=$2 + local TITLE=${INPUT%.md} + TITLE=${TITLE##*/} + if [ "$TITLE" == 'index' ]; then + TITLE='Home' + fi + echo $INPUT + echo $OUTPUT + pandoc -f markdown -t html -o "$OUTPUT" -i "$INPUT" --standalone --template ~/code/site/template.html --variable=pagetitle:"$TITLE" + replace_links "$OUTPUT" +} + +# Replace links in Markdown files with working links to the new HTML files +replace_links() { + local FILE=$1 + # Add .html extensions + # sed -i 's/\(href="\)\([^"]*\)/\1\2.html/g' "$FILE" + sed -Ei.bak '/https|\.[a-z]+/!s/href="[^"]*/&.html/' "$FILE" +} + +setup_files() { + cp ~/code/site/style.css ~/public_html +} + traverse_dir $INPUT_DIR/\* +setup_files popd diff --git a/tmp.html b/tmp.html new file mode 100644 index 0000000..49541e7 --- /dev/null +++ b/tmp.html @@ -0,0 +1,94 @@ + + + + + + + + index | T S Vallender + + + +
+

T S Vallender

+

Software Engineer, nerd, maker and dad.

+
+
+

Learning + plan

+

Foxsoft Todo

+ +

Personal Todo

+ +

Notes

+ +
+ +