install.sh 2.82 KB
Newer Older
1
#!/usr/bin/env bash
2

3
#
4 5
# The suspicious-looking install script for After Dark.
# https://themes.gohugo.io/after-dark/
6
#
Bali Bebas's avatar
Bali Bebas committed
7
# Copyright (c) 2016-2017  Josh Habdas <jhabas@pm.me> (https://habd.as)
8
# Licensed under WTFPL. You just DO WHAT THE FUCK YOU WANT TO.
9
#
10 11

# Exit early on failure
Josh Habdas's avatar
Josh Habdas committed
12
set -e
13

14
# Make some environment variables
15
SITE_SOURCE_PATH=$(pwd)
16 17
HUGO_CONFIG_PATH="./config.toml"

18
# Create new After Dark site
19
if [ -z "$1" ]; then
20
  SITE_SOURCE_PATH="${SITE_SOURCE_PATH}/flying-toasters"
21
  hugo new site flying-toasters && cd $_
22 23 24
else
  SITE_SOURCE_PATH="${SITE_SOURCE_PATH}/$1"
  hugo new site $1 && cd $_
25
fi
26

27
echo "Installing After Dark ..."
28 29

# Clone repo
30
(cd themes; git clone -q --depth 1 https://github.com/comfusion/after-dark || { echo "cloning failed :/"; exit 1; })
31 32 33 34

# Copy archetypes
cp themes/after-dark/archetypes/* ./archetypes

35 36 37 38 39 40 41
# Ignore generated files from source control
touch .gitignore
echo "
public
resources
" >> .gitignore

42 43
# Add pretty config file with inline documentation
tee $HUGO_CONFIG_PATH > /dev/null <<TOML
44
baseurl = "https://c74ce35e.ngrok.io/" # Controls base URL
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
languageCode = "en-US" # Controls site language
title = "After Dark" # Homepage title and page title suffix
paginate = 11 # Number of posts to show before paginating

theme = "after-dark" # Set default theme

enableRobotsTXT = true # Suggested, enable robots.txt file
googleAnalytics = "" # Optional, add tracking Id for analytics
disqusShortname = "" # Optional, add Disqus shortname for comments
SectionPagesMenu = "main" # Enable menu system for lazy bloggers
footnoteReturnLinkContents = "↩" # Provides a nicer footnote return link

[params]
  description = "" # Suggested, controls default description meta
  author = "" # Optional, controls author name display on posts
  hide_author = false # Optional, set true to hide author name on posts
  show_menu = false # Optional, set true to enable section menu
  powered_by = true # Optional, set false to disable credits
  images = [
64
    "https://source.unsplash.com/category/technology/2000x1322"
65 66
  ] # Suggested, controls default Open Graph images
  theme_variant = "" # Optional, for use to overriding default theme
67
TOML
68

69
echo "Creating an example post to get you started ..."
70 71

# Create the first post with next steps for user
72
hugo new post/starry-night.md
73

74
echo "Serving your After Dark site ..."
75

76
# Serve site backgrounded over Docker-friendly loopback
77 78
hugo serve --buildDrafts --port 1337 --bind "0.0.0.0" &

79 80 81
# Wait a second for Hugo server to fire up
sleep 1

82
# Pop the site in terminal browser, if installed
83 84 85
if [[ "elinks" != "" ]]; then
  elinks http://0.0.0.0:1337/
fi
86

87 88 89
echo "Installation complete!"
echo "Your new After Dark site is created in $SITE_SOURCE_PATH."
echo "Site is currently running at http://0.0.0.0:1337/"
90
echo "To stop it run \"kill \$(lsof -nt -i4TCP:1337)\"."
91
echo "Thank you for choosing After Dark."
92 93

exit 0