#!/bin/sh TITLE="19 PDH Puszcza" URL="https://nojs--api-puszcza.netlify.app" DESCRIPTION="" rm -r dest || true mkdir dest # This is useful when deploying on netlify. Thanks to storing compiled binaries # in this folder they will be cached and restored. export PATH="$PWD/.jekyll-cache:$PWD/tools:$PATH" ./tools/compile post_rss() { path="$URL$1" title=$2 photo=$3 description=$4 file=$5 date=`git log -n 1 --date="format:%Y-%m-%dT%H:%M:%SZ" --pretty=format:'%ad' -- $file` cat << EOF $path $path $date $title EOF } post_link() { path=$1 title=$2 photo=$3 description=$4 cat << EOF

$title

$description

EOF } cat > wpisy/kronika.html << EOF

Ostatnie wpisy

RSS

EOF mkdir -p dest/kronika cat > dest/kronika/rss.xml << EOF $TITLE $DESCRIPTION $URL $(date -R) EOF i=0 for f in `find wpisy/kronika/20* -name '*.md' | sort -r`; do path=`echo $f | sed 's/wpisy//;s/.md//'` title=`grep "^# " $f | head -n 1 | cut -c 2-` photo=`grep "!\[.*\]\(.*\)" $f | head -n 1 | cut -d "(" -f2 | cut -d ")" -f1` [ -z $photo ] && photo="/assets/default_tree.jpg" description=`grep -E "^[A-Z]" $f | grep -v "|" | head -n 1 | cut -d" " -f1-30` categories=`sed -n '/---/,/---/p' $f | grep " - " | sed 's/[^a-zA-Z0-9]//g'` post_link "$path" "$title" "$photo" "$description" >> wpisy/kronika.html [ $i -lt 20 ] && \ post_rss "$path" "$title" "$photo" "$description" "$f" >> dest/kronika/rss.xml # [ $i -lt 4 ] && \ # post_link "$path" "$title" "$photo" "$description" >> wpisy/index.md && \ i=$(($i+1)) done echo "
" >> wpisy/kronika.html echo "" >> dest/kronika/rss.xml ./ssg5 wpisy dest "$TITLE" "$URL" cp -r static/* dest