Rewrote templating engine
This commit is contained in:
parent
63dd5fd5b3
commit
577eba63a0
3 changed files with 29 additions and 7 deletions
8
build.sh
8
build.sh
|
@ -9,9 +9,9 @@ mkdir dist&&cd dist
|
|||
cp ../style.css .
|
||||
for file in $(du -a ../src/ | cut -f2 | grep -E '.md$'); do
|
||||
target="$(echo $file | source_to_target)"
|
||||
content="$(pandoc --from markdown+emoji --wrap=none -i $file | sed -e 's/[]\/$*.^[]/\\&/g' | escape_newlines )" # To escape the string for sed later on
|
||||
prefix=$(realpath --relative-to $(dirname $target) .)
|
||||
sidebar=$(for x in ../src/**/*.md; do echo "<li><a href=\"$(echo $prefix/$x | source_to_target)\">$(realpath --relative-to ../src/ $x | sed -e 's/.md$//')</a></li>" | sed -e 's/[]\/$*.^[]/\\&/g' | escape_newlines; done)
|
||||
export CONTENT="$(pandoc --from markdown+emoji --wrap=none -i $file)"
|
||||
export PREFIX=$(realpath --relative-to $(dirname $target) .)
|
||||
export SIDEBAR=$(for x in ../src/**/*.md; do echo "<li><a href=\"$(echo $PREFIX/$x | source_to_target)\">$(realpath --relative-to ../src/ $x | sed -e 's/.md$//')</a></li>"; done)
|
||||
mkdir -p $(dirname $target)
|
||||
cat ../template.tpl | sed -e "s/{CONTENT}/$content/" -e "s:{PREFIX}:$prefix:" -e "s/{SIDEBAR}/$sidebar/" > $target
|
||||
cat ../template.tpl | awk -f ../template.awk | bash > $target
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue