Source code and content for chriswiegman.com https://chriswiegman.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
1.1 KiB

  1. #!/bin/bash
  2. # Uses Hugo to create a new post based on the current date and the provided title
  3. # e.g., new my-awesome-blog-post will create content/YYYY/MM/my-awesome-blog-post/index.md
  4. # Require one argument
  5. if [ $# -eq 0 ]
  6. then
  7. echo "Usage: new <title-of-post>"
  8. exit
  9. fi
  10. yearPrefix=$(date +'%Y')
  11. monthPrefix=$(date +'%Y-%m')
  12. monthName=$(date +'%B')
  13. postTitle=$1
  14. pathSuffix="/index.md"
  15. postPath="posts/$postTitle.md"
  16. hugo new $postPath
  17. if [ ! -f ./content/archy/$yearPrefix.md ]; then
  18. echo '---' >> ./content/archy/$yearPrefix.md;
  19. echo "title: \"Archive for $yearPrefix\"" >> ./content/archy/$yearPrefix.md;
  20. echo "date: \"$yearPrefix-01-01 00:00:00\"" >> ./content/archy/$yearPrefix.md;
  21. echo '---' >> ./content/archy/$yearPrefix.md;
  22. fi
  23. if [ ! -f ./content/archm/$monthPrefix.md ]; then
  24. echo '---' >> ./content/archm/$monthPrefix.md;
  25. echo "title: \"Archive for $monthName, $yearPrefix\"" >> ./content/archm/$monthPrefix.md;
  26. echo "date: \"$monthPrefix-01 00:00:00\"" >> ./content/archm/$monthPrefix.md;
  27. echo '---' >> ./content/archm/$monthPrefix.md;
  28. fi