boh-blog/boh.config

45 lines
1.4 KiB
Text

export site_name="Your Blog"
boh_pre_build() {
echo "Build index"
boh_blog_build_index
}
boh_post_build() {
rm $source_dir"/index.md"
echo "Moving posts"
boh_blog_move_posts
echo "Coping assets"
if [ -d "$source_dir/_assets" ];then
cp -R "$source_dir/_assets/"* "$destination_dir"
fi
}
boh_blog_move_posts(){
cut_at=`echo "/$destination_dir/posts/" | fold -w 1 | grep / -c`
for file in `ls $destination_dir/posts/*.html`; do
base_date=`echo $file | cut -d / -f $cut_at | cut -d - -f -3`
newpath="$destination_dir/posts/"`date --date="$base_date" "+%Y/%m/%d"`"/"
mkdir -p $newpath
newpath=$newpath`echo $file | rev | cut -d / -f 1 | rev | cut -d - -f 4-`
mv $file $newpath
done
}
boh_blog_build_index(){
cat <<EOF > "$source_dir/index.md"
---
layout: index
---
EOF
cut_at=`echo "/$source_dir/posts/" | fold -w 1 | grep / -c`
for file in `ls $source_dir/posts/*.md | sort -r`; do
base_date=`echo $file | cut -d / -f $cut_at- | cut -d - -f -3`
date=`date --date="$base_date" "+ %a %d, %b %Y"`
link="/posts/"`date --date="$base_date" "+%Y/%m/%d"`"/"`echo $file | rev | cut -d / -f 1 | rev | sed 's/.md/.html/' | cut -d - -f 4-`
frontmatter=`boh_parse_frontmatter $file`
eval $frontmatter
echo "<li><span class=\"post-meta\">$date</span><h2><a class =\"post-link\" href=\"$link\">$title</a></h2></li>" >> "$source_dir/index.md"
done
}