Quick Install

Hanya satu perintah yang anda butuhkan untuk membuat website baru.

After Dark termasuk skrip instalasi portabel untuk pengaturan cepat:

themes/after-dark/bin/install
Perluas untuk melihat skrip
  1#!/bin/sh
  2
  3validate_hugo () {
  4   # Exit with error if hugo is not installed
  5   if ! hash hugo 2>/dev/null ; then
  6     echo "Error: After Dark requires Hugo version 0.44 or greater" >&2; exit 1
  7   fi
  8
  9   # Exit with error if not minimum required hugo version
 10   re="v(0\d*\.([4-9][4-9]|[5-9])|[1-9]).*"
 11   if ! hugo version | grep -qE "$re" ; then
 12      echo "Error: After Dark requires Hugo version 0.44 or greater" >&2; exit 1
 13   fi
 14}
 15
 16create_site_dir () {
 17   SITE_DIR="flying-toasters"
 18   if [ "$1" != "" ] ; then
 19      SITE_DIR="$1"
 20   fi
 21
 22   SITE_DIR_ABS="$PWD/$SITE_DIR"
 23   mkdir -p "$SITE_DIR"
 24}
 25
 26create_site () {
 27   echo "Creating a new Hugo site ..."
 28   hugo new site "$SITE_DIR" 1>/dev/null
 29   cd "$SITE_DIR" || exit 1
 30}
 31
 32download_theme () {
 33   echo "Downloading the latest version of After Dark ..."
 34   LATEST_META=$(wget -qO - https://registry.npmjs.org/after-dark/latest)
 35   vers=$(echo "$LATEST_META" | egrep -o "\"version\".*[^,]*," | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '" ')
 36   mkdir -p themes/after-dark
 37   wget -qO - https://registry.npmjs.org/after-dark/-/after-dark-"$vers".tgz | tar --strip-components=1 -xz -C themes/after-dark
 38   echo "Version $vers downloaded to $SITE_DIR/themes/after-dark"
 39}
 40
 41download_module () {
 42   [ -z "$1" ] && { echo "Error: Attempt to download undefined module" >&2; exit 1; }
 43   echo "Downloading $1 module for After Dark ..."
 44   meta=$(wget -qO - https://registry.npmjs.org/"$1"/latest)
 45   vers=$(echo "$meta" | egrep -o "\"version\".*[^,]*," | cut -d ',' -f1 | cut -d ':' -f2 | tr -d '" ')
 46   mkdir -p themes/"$1"
 47   wget -qO - https://registry.npmjs.org/"$1"/-/"$1"-"$vers".tgz | tar --strip-components=1 -xz -C themes/"$1"
 48   echo "Version $vers downloaded to $SITE_DIR/themes/$1"
 49}
 50
 51configure_theme () {
 52   echo "Configuring basic After Dark theme settings ..."
 53   tee "config.toml" > /dev/null <<TOML
 54baseurl = "https://domain.example" # Controls base URL sitewide
 55languageCode = "en-US" # Controls site language
 56title = "After Dark" # Homepage title and page title suffix
 57paginate = 11 # Number of posts to show before paginating
 58
 59# Controls default theme and theme components
 60theme = [
 61  "fractal-forest",
 62  "after-dark"
 63]
 64
 65disableLiveReload = false # Optional, set true to disable live reload
 66enableRobotsTXT = true # Suggested, enable robots.txt file
 67
 68pygmentsCodefences = true # Suggested, highlight fenced code blocks
 69pygmentsUseClasses = true # Required for custom syntax highlighting
 70
 71sectionPagesMenu = "main" # Enable menu system for lazy bloggers
 72footnoteReturnLinkContents = "↩" # Provides a nicer footnote return link
 73
 74[params]
 75  description = "" # Suggested, controls default description meta
 76  author = "" # Optional, controls author name display on posts
 77  hide_author = false # Optional, set true to hide author name on posts
 78  has_cookies = false # Optional, set true to disable cookie disclaimer
 79  disable_csp = false # Optional, set true to disable content security policy
 80  images = [
 81    "https://source.unsplash.com/collection/983219/2000x1322"
 82  ] # Suggested, controls default Open Graph images
 83
 84[params.layout.menu.main]
 85  hidden = true # Optional, set false or remove to show section menu
 86
 87[params.modules.fractal_forest]
 88  enabled = true # Optional, set false to disable module
 89  decoders = ["bpgdec8a"] # Optional, 8-bit javascript decoder with animation
 90TOML
 91}
 92
 93update_archetypes () {
 94   echo "Updating the default content archetype ..."
 95   rm -f archetypes/default.md
 96   cp themes/after-dark/archetypes/default.md archetypes
 97}
 98
 99create_welcome_post () {
100   echo "Creating welcome post ..."
101   hugo new post/welcome.md 1>/dev/null
102}
103
104serve_site () {
105   echo "Starting site server ..."
106   hugo serve --buildDrafts --navigateToChanged --port 1313 1>/dev/null &
107}
108
109generate_help_docs () {
110   echo "Generating help documentation ..."
111   THEME_PATH=themes/after-dark
112   meta_path="$THEME_PATH"/data/npm
113   mkdir -p "$meta_path" && echo "$LATEST_META" | tr '\r\n' ' ' > "$meta_path"/latest.json
114   cd "$THEME_PATH"/docs && mkdir themes && ln -s ../.. "$THEME_PATH"
115   hugo new validate.md --kind validate 1>/dev/null
116}
117
118serve_help () {
119   echo "Starting help server ..."
120   hugo serve --disableLiveReload --port 1414 1>/dev/null &
121}
122
123set -e
124
125echo "Welcome to the After Dark quick installer. Press CTRL-C at any time to abort."
126
127validate_hugo
128create_site_dir "$1"
129create_site
130download_theme
131update_archetypes
132download_module "fractal-forest"
133configure_theme
134create_welcome_post
135serve_site
136generate_help_docs
137serve_help
138
139YELLOW='\033[0;33m'
140NC='\033[0m'
141
142printf "${YELLOW}Installation successful!${NC}\n"
143echo "Site created in $SITE_DIR_ABS"
144echo "Site server started at http://localhost:1313/"
145echo "To stop it run \"kill \$(ps aux | awk '/[h]ugo.*1313/ {print \$2}')\"."
146echo "Help server started at http://localhost:1414/"
147echo "To stop and restart it run \"./themes/after-dark/bin/help\"."
148echo "Thank you for choosing After Dark."

Silahkan instal Hugo 0.44 atau yang lebih besar sebelum menjalankan skrip.

Skrip telah diuji pada Debian, BusyBox dan Darwin, dan seharusnya juga dapat bekerja di bawah Alpine, Ubuntu, Docker dan Windows melalui Cmder tanpa ketergantungan tambahan.

Warning: selalu periksa skrip yang diunduh dari internet sebelum menjalankannya secara lokal. Jika anda memilih untuk tidak menjalankan skrip Unduh secara manual.

Jalankan skrip sesuka anda. Berikut adalah metode yang memungkinkan:

  1. Unduh dan kirim ke sh secara langsung:

    wget -qO - https://go.habd.as/after-dark | sh

    (Cojones not included.)

  2. Unduh di file baru, chmod dan jalankan:

    curl -O https://cdn.jsdelivr.net/npm/after-dark@latest/bin/install && \
    chmod +x install && ./install

    (It’s safe if it comes from a CDN, amirite?)

  3. Dari kanonik git klon:

    # sumber klon dan ubah ke direktori sumber git klon https://git.habd.as/comfusion/after-dark.git && cd "$_"
    
    # gunakan npm cli untuk mendapatkan hash rilis
    echo "${$(npm run integrity)#*sha512-}"
    
    # jalankan instal cepat setelah memvalidasi
    ./bin/install

    (Release Hashes may be used for code validation.)

Skrip harus selesai dalam 5-10 detik sehingga menghasilkan sampel situs dan dokumen bantuan:

After Dark screenshots
After Dark Quick Install running to completion in Terminal on macOS Mojave.

Konfigurasi multi situs

After Dark memungkingkan menjalankan manajemen multi situs dari satu instalasi. Untuk mengelola beberapa website gunakan -c dan -d bendera untuk menentukan konten dan tujuan direktori secara berurutan.

Misalnya, untuk mengahasilkan situs audio menggunakan instalasi After Dark saat ini, buat skrip yang dapat dieksekusi untuk menghasilkan situs tersebut:

flying-toasters/bin/gen-audio-site
#!/bin/sh
hugo -c sites/audio -d public/static.domain.example

Dimana audio berisi konten untuk situs itu:

├── layouts
├── sites
│   └── audio
│       ├── audiobooks
│       │   ├── gaining-currency.md
│       │   └── the-power-of-now.md
│       └── clips
│           └── war-of-the-worlds.md
├── static

Dan public berisi folder untuk setiap situs:

public
└── static.domain.example
    ├── categories
    │   └── index.xml
    ├── audiobooks
    │   └── index.html
    ├── clips
    │   └── index.html
    ├── css
    ├── index.html
    ├── index.xml
    ├── js
    ├── sitemap.xml
    └── tags
        └── index.xml

Dan buat skrip lain untuk menyajikan konten untuk diedit:

flying-toasters/bin/serve-audio-site
#!/bin/sh
hugo -c sites/audio

Setiap subdirektori public kemudian menjadi website yang independen dan dapat disebarkan serta salinan persisnya disimpan untuk konten tujuan yang dihasilkan.

Tip: Untuk jenis fleksibiltas tambahan hugo --help dan modifikasi skrip anda menggunakan --theme dan --config flags.

Multi situs sangat cocok untuk mempertahankan tampilan dan rasa yang konsisten di berbagai domain asal sekaligus membatasi kebutuhan untuk menjalankannya Upgrade Script untuk setiap situs.