No Description
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.

live 1.2KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. # Runs command in requested directory in the background
  3. # and restores the working directory at the end.
  4. # Usage: runInBackground <directory> "<command>"
  5. runInBackground(){
  6. pushd $1 >/dev/null
  7. eval $2 &
  8. popd >/dev/null
  9. }
  10. # With thanks to Job Vranish for his awesome tutorial
  11. # on starting/stopping background processes in Bash:
  12. # https://spin.atomicobject.com/2017/08/24/start-stop-bash-background-process/
  13. trap "exit" INT TERM ERR
  14. trap "kill 0" EXIT
  15. # Start the rsync deployment watcher
  16. runInBackground ../sync "npm run sync"
  17. # Start Hugo server.
  18. #
  19. # The baseURL and appendPort flags are set to overwrite the default behaviour
  20. # of Hugo when run with the server option which is to write absolute URLs
  21. # as localhost:<port> regardless of the setting of baseURL in the config.toml
  22. # file. Since we do not have a separate build/deploy phase to the live server,
  23. # we want the site as it would exist on the server to exist on the client.
  24. #
  25. # Note: if you do not want a post live-synced, mark it as draft: true in the
  26. # ===== front matter.
  27. #
  28. hugo server --renderToDisk --baseURL=https://davidpeach.co.uk --appendPort=false
  29. # Don’t exit. Shutting off this process should also kill
  30. # the two other background processes we started
  31. wait