diff --git a/boh.config b/boh.config new file mode 100644 index 0000000..67a637f --- /dev/null +++ b/boh.config @@ -0,0 +1,44 @@ +export site_name="Your Blog" + +boh_pre_build() { + echo "Build index" + boh_blog_build_index +} + +boh_post_build() { + 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 < "$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=`parse_frontmatter $file` + eval $frontmatter + echo "
  • $date

    $title

  • " >> "$source_dir/index.md" + done +}