First working version
This commit is contained in:
parent
09209d2637
commit
938250ae37
|
@ -15,7 +15,7 @@ date=$(echo "$frontmatter" | awk -F'=' '/date=/ {print $2}')
|
|||
printf '<!doctype html>\n'
|
||||
printf '<html>\n'
|
||||
printf '<head>\n'
|
||||
printf '<title>%s</title>\n' "$title"
|
||||
printf "<title>%s | cren's webspace</title>\n" "$title"
|
||||
printf '<link rel="icon" href="favicon.ico" type="image/x-icon">\n'
|
||||
printf '<link rel="stylesheet" href="cren.css">\n'
|
||||
printf '<meta charset="utf8">\n'
|
||||
|
@ -24,9 +24,12 @@ printf '</head>\n'
|
|||
printf '<body>\n'
|
||||
printf '<header>\n'
|
||||
printf "<h1>cren's webspace</h1>\n"
|
||||
printf '<h2>%s</h2>\n' "$title"
|
||||
printf '<date datetime=%s>%s</date>' "$date" "$date"
|
||||
printf '</header>\n'
|
||||
printf '<main>\n'
|
||||
# Now we insert the main content of the page
|
||||
# Also insert a <date> element in the header after the heading, based on the `date` metadata item
|
||||
printf '%s' "$(echo "$docbody" | cmark)"
|
||||
printf '</main>\n'
|
||||
# Finally, the footer
|
||||
|
|
26
render_tree
26
render_tree
|
@ -1,3 +1,29 @@
|
|||
#!/bin/sh
|
||||
# render_tree: render all the files in a directory tree to html or just copy them
|
||||
# if they are not markdown
|
||||
# arguments:
|
||||
# $1: input directory path
|
||||
# $2: output directory path
|
||||
|
||||
traverse_dir() {
|
||||
# Iterate over files in the given directory
|
||||
for file in "$1"/*
|
||||
do
|
||||
# Recurse into directories in the given directory
|
||||
if [ -d "$file" ]
|
||||
then
|
||||
printf '%s is a directory, recursing...' "$file" >&2
|
||||
traverse_dir "$file" "$2"
|
||||
elif [ -f "$file" ]
|
||||
then
|
||||
printf 'Rendering %s...' "$file" >&2
|
||||
# Use basename to strip the .md suffix from markdown files, then
|
||||
# append .html
|
||||
name="$(basename -s .md "$file")"
|
||||
./render_file "$file" > "$2"/"$name".html
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
traverse_dir "$1" "$2"
|
||||
printf 'Done.\n' >&2
|
||||
|
|
Loading…
Reference in New Issue