diff options
author | Tyler Davis <tyler@gluecode.net> | 2025-03-04 19:36:15 +0000 |
---|---|---|
committer | Tyler Davis <tyler@gluecode.net> | 2025-03-04 19:36:15 +0000 |
commit | b7354ac9db8cca1742bffc13b4fa96bfdf6bd263 (patch) | |
tree | ab8936afafea25e4f3d9e15911babdc77f84d0c9 /gen.sh | |
parent | b26044cfbd391c2aec809f4193fc967fae2ee9aa (diff) | |
download | journal-b7354ac9db8cca1742bffc13b4fa96bfdf6bd263.tar.gz journal-b7354ac9db8cca1742bffc13b4fa96bfdf6bd263.zip |
gen: more fixes to output
Diffstat (limited to 'gen.sh')
-rwxr-xr-x | gen.sh | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1,7 +1,7 @@ #!/usr/bin/env sh WORKDIR=$PWD -OUTDIR=/var/www/blog/ +OUTDIR=/var/www/blog verbose=0 # Variables to be evaluated as shell arithmetic should be initialized to a default or validated beforehand. if [ ! "$(command -v lowdown)" ]; then @@ -84,19 +84,25 @@ EOF # Make out dir if [ ! -d "${OUTDIR}" ]; then mkdir ${OUTDIR} ; fi +# Remove posts and drafts if present +if [ -d "${OUTDIR}/posts" ]; then rm -rf "${OUTDIR}/posts" ; fi +if [ -d "${OUTDIR}/draft" ]; then rm -rf "${OUTDIR}/draft" ; fi + MDLIST=$(eval "find ${WORKDIR} -type f -name \"*.md\" ") for m in $MDLIST; do # shortpath trims the working directory prefix shortpath=$(eval "echo $m | sed -e 's,${WORKDIR}/,,' ") BNAME=$(eval "basename $m") - dirpath=$(eval "echo $m | sed -e 's,${WORKDIR}/,,' -e 's,${BNAME},,' ") + dirpath=$(eval "dirname $shortpath") filename=$(eval "echo ${BNAME} | sed -e 's,\.md,,' ") if [ $verbose -gt 0 ]; then echo "Processing: ${shortpath}" fi + OUTPATH="${OUTDIR}/${dirpath}/${filename}.html" + if [ ! -d "${OUTDIR}/${dirpath}" ]; then mkdir -p "${OUTDIR}/${dirpath}" ; fi # Output directly to file if $dirpath ends in ".md" for root-level files case $dirpath in *.md) @@ -105,7 +111,6 @@ for m in $MDLIST; do *) # Make the outdir if not ending in ".md" - if [ ! -d "${OUTDIR}/${dirpath}" ]; then mkdir ${OUTDIR}/${dirpath} ; fi esac echo $HEADER > "${OUTPATH}" |