-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·68 lines (55 loc) · 1.8 KB
/
Makefile
File metadata and controls
executable file
·68 lines (55 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Makefile for building and publishing a site
# Directories
PUBLIC_DIR := ./docs
POSTS_PUBLIC_DIR := $(PUBLIC_DIR)/posts
LOCAL_DIR := content
SHELL := /bin/bash
# Targets
.DEFAULT_GOAL := preview
install_js:
@if [ ! -d "node_modules" ]; then \
echo "Installing JS dependencies..."; \
npm install csso-cli uglify-js pagefind; \
fi
minify: install_js
mkdir -p docs/src
npx csso-cli content/src/rougier.css -o docs/src/rougier.min.css
npx uglifyjs content/src/copy-pre.js -o docs/src/copy-pre.min.js
npx uglifyjs content/src/theme-switcher.js -o docs/src/theme-switcher.min.js
@if [ -f content/src/nav.js ]; then \
npx uglifyjs content/src/nav.js -o docs/src/nav.min.js; \
fi
@if [ -f content/src/search.js ]; then \
npx uglifyjs content/src/search.js -o docs/src/search.min.js; \
fi
pagefind:
npx pagefind --site $(PUBLIC_DIR)
# Remove local directory
clean:
echo "Cleaning public dir"
@if [ -d $(PUBLIC_DIR) ]; then \
rm -rf $(PUBLIC_DIR) && echo "Local directory deleted"; \
fi
rm -rf ~/.org-timestamps/*.cache
cleanup:
echo "Cleaning static files (non-included images) under content/posts"
zsh scripts/cleanup.sh
# Necessary for publishing purposes
add_cname:
echo "blog.chatziiola.live" > $(PUBLIC_DIR)/CNAME
# Build the site using Emacs
emacs:
@echo "Running emacs build"
emacs -Q --script scripts/build-site.el
copy_static:
cp -r $(LOCAL_DIR)/src $(PUBLIC_DIR)
cp $(LOCAL_DIR)/src/robots.txt $(PUBLIC_DIR)
build: cleanup minify emacs copy_static pagefind
# Turns out git restore is not such good option most of the time
preview:
@echo "Will now preview locally; make sure to use publish later on"
$(MAKE) build
trap 'git restore $(PUBLIC_DIR)' SIGINT; python3 -m http.server -d $(PUBLIC_DIR)
full_build:
@echo "Publishing. Make sure to have DRAFT on unfinished posts"
$(MAKE) clean build