bash3boilerplate/website/_bin/build.sh
Kevin van Zonneveld d0ece6da76 Website (#30)
* Base on apex.run

* More custom themie

* Loop to write

* Support inline links

* Smaller header

* Auto-deploys via travis

* Rewording to make for a better homepage
2016-06-21 09:40:25 +02:00

46 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
# set -o xtrace
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__webroot="$(cd "$(dirname "${__dir}")" && pwd)"
for doc in "README" "FAQ" "CHANGELOG"; do
targetName="$(echo "${doc}" | awk '{print tolower($0)}')"
permalink="/${targetName}/"
subtitle="$(tr '[:lower:]' '[:upper:]' <<< ${targetName:0:1})${targetName:1} | "
redirectFrom="/${doc}.md/"
if [ "${doc}" = "README" ]; then
targetName="index"
permalink="/"
subtitle=""
redirectFrom="nothing"
fi
cat <<EOF > website/${targetName}.md
---
layout: default
permalink: ${permalink}
redirect_from: ${redirectFrom}
title: ${subtitle}BASH3 Boilerplate the delete-key friendly template for writing better BASH scripts
warning: This page is generated by ${__base}.sh based on ${doc}.md, please don't edit ${targetName}.md directly.
---
EOF
# http://stackoverflow.com/a/7104422/151666
cat ${doc}.md |sed -n -e '/<!--more-->/,$p' | tail -n +2 >> website/${targetName}.md
echo "written website/${targetName}.md"
done
if [ "${TRAVIS:-}" = "true" ]; then
pushd "${__webroot}"
bundle install --path ./_vendor || bundle update --path ./_vendor
bundle exec jekyll build
popd
fi