From f3ae3c251d073c3888be31b6505a9b4938dfd70a Mon Sep 17 00:00:00 2001 From: John Ramsden Date: Thu, 27 Jul 2017 18:55:06 -0700 Subject: [PATCH] Created 'createtag' script to create tag pages. Running the script from the root directory of the project will create a tag page in 'pages/tags' for every parameter input into the script and tag_${tag}.md will contain the following. --- title: "${tag} Posts" tagName: ${tag} search: exclude permalink: tag_${tag}.html sidebar: mydoc_sidebar hide_sidebar: true folder: tags --- {% include taglogic.html %} {% include links.html %} It should be easy to replace this with altered content if it is unsatisfactory. --- createtag | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 createtag diff --git a/createtag b/createtag new file mode 100644 index 0000000..1ec23dd --- /dev/null +++ b/createtag @@ -0,0 +1,50 @@ +#!/bin/sh + +# Using a 'cat' here document, create a file for jekyll +# website containing what's required for tag pages. + +# Pass in tag name(s) +# ./createtag linux bsd + +CMDLINEPARAM=1 # Takes at least one param. +TAGDIR="pages/tags" + +if [ $# -ge $CMDLINEPARAM ] +then + tags=$@ +else + echo "Atleast ${CMDLINEPARAM} tag name is required." + exit 1 +fi + +if [ -d "${TAGDIR}" ]; then + + echo "Creating tag(s) for ${tags}" + + for tag in ${tags}; do + # Cannot indent here string. +cat <"${TAGDIR}/tag_${tag}.md" +--- +title: "${tag} Posts" +tagName: ${tag} +search: exclude +permalink: tag_${tag}.html +sidebar: mydoc_sidebar +hide_sidebar: true +folder: tags +--- + +{% include taglogic.html %} + +{% include links.html %} +EOF + + done + +else + echo "Directory ${TAGDIR} doesn't exist or you are not in the top-level directory." + echo "Please run again from the root directory of your project." + exit 1 +fi + +exit