pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit f534bbc4b3ab8c613a3dc41bfe2fc09c65b2a9a0
parent b32bd86c0d430c01a34bb03cf11be39d66752af1
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 14 Jan 2021 09:52:09 +0000

updated to allow bulk content

Diffstat:
Mpyratelog.sh | 40++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/pyratelog.sh b/pyratelog.sh @@ -2,29 +2,33 @@ function initialise() { cd /blog - input=$(find content/ -type f -name "*.md" | cut -f2 -d '/' | cut -f1 -d '.') - input_date=$(echo ${input} | cut -f1 -d '-' ) - input_date=$(date -d ${input_date} +%Y\ %m\ %d) - input_title=$(echo ${input} | cut -f2 -d '-' | sed 's/_/\ /g') - input_link="<li><a class="index" href='content/${input}.html'>${input_date} - ${input_title}</a></li>" + find_md=$(find content/ -type f -name "*.md") + for md in ${find_md} ; do + input=$(echo ${md} | cut -f2 -d '/' | cut -f1 -d '.') + input_date=$(echo ${input} | cut -f1 -d '-' ) + input_date=$(date -d ${input_date} +%Y\ %m\ %d) + input_title=$(echo ${input} | cut -f2 -d '-' | sed 's/_/\ /g') + input_link="<li><a class="index" href='content/${input}.html'>${input_date} - ${input_title}</a></li>" - grep ${input} index.html >/dev/null && return + grep ${input} index.html >/dev/null && return - pandoc -s \ - --template=./post_template.html \ - --metadata title="${input_title}" \ - -f markdown \ - -t html \ - -o content/${input}.html \ - content/${input}.md - - sed "/<ul>/a ${input_link}" index.html > index.html.bak + pandoc -s \ + --template=./post_template.html \ + --metadata title="${input_title}" \ + -f markdown \ + -t html \ + -o content/${input}.html \ + content/${input}.md + + sed "/<ul>/a ${input_link}" index.html > index.html.bak - cat index.html.bak >index.html + cat index.html.bak >index.html - rm -f content/${input}.md index.html.bak + rm -f content/${input}.md index.html.bak + done } while : ; do - [ -f /blog/content/*.md ] && initialise || sleep 30 + #[ -f /blog/content/*.md ] && initialise || sleep 30 + ls ./content/*.md >/dev/null 2>&1 && initialise || sleep 30 done