createtag 977 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # Using a 'cat' here document, create a file for jekyll
  3. # website containing what's required for tag pages.
  4. # Pass in tag name(s)
  5. # ./createtag linux bsd
  6. CMDLINEPARAM=1 # Takes at least one param.
  7. TAGDIR="pages/tags"
  8. if [ $# -ge $CMDLINEPARAM ]
  9. then
  10. tags=$@
  11. else
  12. echo "Atleast ${CMDLINEPARAM} tag name is required."
  13. exit 1
  14. fi
  15. if [ -d "${TAGDIR}" ]; then
  16. echo "Creating tag(s) for ${tags}"
  17. for tag in ${tags}; do
  18. echo "Title for $tag:"
  19. read title
  20. # Cannot indent here string.
  21. cat <<EOF >"${TAGDIR}/tag_${tag}.md"
  22. ---
  23. title: "${title}"
  24. tagName: ${tag}
  25. search: exclude
  26. permalink: tag_${tag}.html
  27. sidebar: mydoc_sidebar
  28. hide_sidebar: true
  29. folder: tags
  30. ---
  31. {% include taglogic.html %}
  32. {% include links.html %}
  33. EOF
  34. echo " - ${tag}" >> _data/tags.yml
  35. done
  36. else
  37. echo "Directory ${TAGDIR} doesn't exist or you are not in the top-level directory."
  38. echo "Please run again from the root directory of your project."
  39. exit 1
  40. fi
  41. exit