boh.config 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. export site_name="Your Blog"
  2. boh_pre_build() {
  3. echo "Build index"
  4. boh_blog_build_index
  5. }
  6. boh_post_build() {
  7. echo "Moving posts"
  8. boh_blog_move_posts
  9. echo "Coping assets"
  10. if [ -d "$source_dir/_assets" ];then
  11. cp -R "$source_dir/_assets/"* "$destination_dir"
  12. fi
  13. }
  14. boh_blog_move_posts(){
  15. cut_at=`echo "/$destination_dir/posts/" | fold -w 1 | grep / -c`
  16. for file in `ls $destination_dir/posts/*.html`; do
  17. base_date=`echo $file | cut -d / -f $cut_at | cut -d - -f -3`
  18. newpath="$destination_dir/posts/"`date --date="$base_date" "+%Y/%m/%d"`"/"
  19. mkdir -p $newpath
  20. newpath=$newpath`echo $file | rev | cut -d / -f 1 | rev | cut -d - -f 4-`
  21. mv $file $newpath
  22. done
  23. }
  24. boh_blog_build_index(){
  25. cat <<EOF > "$source_dir/index.md"
  26. ---
  27. layout: index
  28. ---
  29. EOF
  30. cut_at=`echo "/$source_dir/posts/" | fold -w 1 | grep / -c`
  31. for file in `ls $source_dir/posts/*.md | sort -r`; do
  32. base_date=`echo $file | cut -d / -f $cut_at- | cut -d - -f -3`
  33. date=`date --date="$base_date" "+ %a %d, %b %Y"`
  34. 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-`
  35. frontmatter=`parse_frontmatter $file`
  36. eval $frontmatter
  37. echo "<li><span class=\"post-meta\">$date</span><h2><a class =\"post-link\" href=\"$link\">$title</a></h2></li>" >> "$source_dir/index.md"
  38. done
  39. }