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.

41 lines
1.1KB

  1. #!/bin/bash
  2. # Load data
  3. printf '%s' "Enter Title: "
  4. read -r
  5. title="$REPLY"
  6. printf '%s' "Enter Author: "
  7. read -r
  8. author="$REPLY"
  9. printf '%s' "Enter Category: "
  10. read -r
  11. category="$REPLY"
  12. title="${title/\//}"
  13. # Slug | lowercase, without accent mark
  14. lug=$(printf '%s' "${title// /-}")
  15. slug=$(echo "$lug" | sed 'y/áÁàÀãÃâÂéÉêÊíÍóÓõÕôÔúÚñÑçÇ/aAaAaAaAeEeEiIoOoOoOuUnNcC/' | sed -e 's/\(.*\)/\L\1/')
  16. printf '%s' "Enter Tags: "
  17. read -r
  18. tag="$REPLY"
  19. # output
  20. o_author=$(printf '%s%s\n' "Author: " "$author")
  21. o_category=$(printf '%s%s\n' "Category: " "$category")
  22. o_date=$(printf '%s%s\n' "Date: " "$(date +"%Y-%m-%d %I:%M")")
  23. o_slug=$(printf '%s%s\n' "Slug: " "$slug")
  24. o_tag=$(printf '%s%s\n' "Tags: " "$tag")
  25. o_title=$(printf '%s%s\n' "Title: " "$title")
  26. # export to file.md
  27. printf '%s\n%s\n%s\n%s\n%s\n%s\n' "$o_author"\
  28. "$o_category"\
  29. "$o_date"\
  30. "$o_slug"\
  31. "$o_tag"\
  32. "$o_title" > "content/articles/$slug.md"