Generate static files as part of the build process

This commit is contained in:
2022-12-30 15:41:50 -08:00
parent 29e03c2732
commit e7615c4947
4 changed files with 30 additions and 64 deletions

View File

@@ -1,14 +1,23 @@
source $stdenv/setup
# Set up Ruby to use UTF-8
export RUBYOPT="-KU -E utf-8:utf-8"
# Copy files to a mutable directory.
cp -r $src/* .
# Hugo can't set baseUrl via CLI for multi-lingual hosts.
# We have to manually edit the configuration.
patchPhase
# We'll generate some static files so make static writable
chmod -R u+w .
# Build site with Hugo
hugo $extraFlags
hugo $hugoFlags --config=config.toml,config-gen.toml
# Create generated files
# Can't do submodules because nix flake inputs get their .git deleted
ruby ./analyze.rb > static/graph/graph.gen.js # Graph files
stork build --input public/index.toml --output static/index.st # Search index
# Static folder changed, re-run Hugo
hugo $hugoFlags --config=config.toml,config-gen.toml
# Output result
mkdir $out