aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-05-06 21:33:15 +0000
committerEgor Tensin <Egor.Tensin@gmail.com>2020-05-06 21:33:15 +0000
commit56553e4dd0a4880fe0cf3b11ebddbc551b44bbe8 (patch)
tree50fbaa6b729d6c5b33b690fc98c6b624e6594fe9
parentREADME: update (diff)
downloadjekyll-docker-56553e4dd0a4880fe0cf3b11ebddbc551b44bbe8.tar.gz
jekyll-docker-56553e4dd0a4880fe0cf3b11ebddbc551b44bbe8.zip
Makefile: automatic --config detection for Jekyll
-rw-r--r--Makefile21
1 files changed, 18 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 44b9211..8f5c0a6 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,10 @@ SHELL := bash
.DELETE_ON_ERROR:
.SUFFIXES:
+empty :=
+space := $(empty) $(empty)
+comma := ,
+
makefile_dir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
# Jekyll project is in the parent directory by default.
@@ -78,8 +82,8 @@ chruby/profile.d/clean:
chruby := . '$(chruby_sh)' && chruby 'ruby-$(RUBY_VERSION)'
project_chruby := cd -- '$(PROJECT_DIR)' && $(chruby)
+
bundle := $(project_chruby) && bundle
-jekyll := $(bundle) exec jekyll
.PHONY: bundler
bundler:
@@ -99,13 +103,24 @@ deps: dependencies
.PHONY: deps/update
deps/update: dependencies/update
+# List of --config files in alphabetical order.
+jekyll_configs := $(shell cd -- '$(PROJECT_DIR)' && find . -mindepth 1 -maxdepth 1 -type f -name '_config*.yml' -print | sort)
+jekyll_configs := $(subst $(space),$(comma),$(jekyll_configs))
+
+jekyll_opts := --drafts --config $(jekyll_configs)
+jekyll := $(bundle) exec jekyll
+
+.PHONY: foo
+foo:
+ echo $(configs)
+
.PHONY: jekyll/build
jekyll/build:
- $(jekyll) build --drafts --config _config.yml,_config_dev.yml
+ $(jekyll) build $(jekyll_opts)
.PHONY: jekyll/serve
jekyll/serve:
- $(jekyll) serve --drafts --config _config.yml,_config_dev.yml --host 0.0.0.0
+ $(jekyll) serve $(jekyll_opts) --host 0.0.0.0
JEKYLL_UID ?= $(shell id -u)
JEKYLL_GID ?= $(shell id -g)