-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (86 loc) · 3.12 KB
/
Makefile
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
SHELL := /bin/bash
OUTPUT = docs
CONTENT_DIR = content/
POSTS_DIR = content/posts
INFO_DIR = content/info
TEMPLATE_DIR = content/templates
POSTS = $(shell find $(POSTS_DIR) -name '*.md' -printf '%f\n' | sed -E 's/(.*)\.md/$(OUTPUT)\/posts\/\1.html/g')
INFO_PAGES = $(shell find $(INFO_DIR) -name '*.md' -printf '%f\n' | sed -E 's/(.*)\.md/$(OUTPUT)\/\1.html/g')
CSS_FILES = $(shell ls content/css/*.css)
IMAGES = $(shell find content/images -name '*.*' -printf '$(OUTPUT)/images/%f\n')
META_FILES = $(shell find content/metadata -name '*' -printf '$(OUTPUT)/%f\n' | tail +2)
TARGET_CSS = $(OUTPUT)/css/style.css
build: directories webfonts $(TARGET_CSS) $(IMAGES) $(POSTS) $(INFO_PAGES) $(OUTPUT)/index.html $(OUTPUT)/archive.html $(META_FILES) generate-feeds
generate-feeds: install-tools
@echo "generating feeds"
@feed
directories: $(OUTPUT)/webfonts $(OUTPUT)/css $(OUTPUT)/images $(OUTPUT)/posts
$(OUTPUT)/webfonts $(OUTPUT)/images $(OUTPUT)/css $(OUTPUT)/posts:
@echo "creating missing directories"
@mkdir -p $@
$(OUTPUT)/images/%: content/images/%
@echo "copying missing images"
@cp $< $@
webfonts:
@echo "copying webfonts"
@cp content/webfonts/*.woff* $(OUTPUT)/webfonts/
$(TARGET_CSS): $(CSS_FILES)
@echo "creating CSS files"
@cat $(CSS_FILES) > $@
$(OUTPUT)/posts/%.html: $(POSTS_DIR)/%.md
@echo "converting posts"
@pandoc \
--standalone \
--css=../css/style.css \
--highlight-style=pygments \
--include-before-body=$(TEMPLATE_DIR)/header.html \
--include-after-body=$(TEMPLATE_DIR)/footer.html \
--template=$(TEMPLATE_DIR)/post.html \
-i $< -o $@
$(OUTPUT)/%.html: $(INFO_DIR)/%.md
@echo "converting main pages"
@pandoc \
--standalone \
--css=css/style.css \
--highlight-style=pygments \
--include-before-body=$(TEMPLATE_DIR)/header.html \
--include-after-body=$(TEMPLATE_DIR)/footer.html \
--template=$(TEMPLATE_DIR)/default.html \
-i $< -o $@
$(OUTPUT)/index.html: $(OUTPUT)/index_metadata.yml
@echo "creating index.html"
@pandoc \
--standalone \
--css=css/style.css \
--include-before-body=$(TEMPLATE_DIR)/header.html \
--include-after-body=$(TEMPLATE_DIR)/footer.html \
--template=$(TEMPLATE_DIR)/index.html \
--metadata-file=$< \
-o $@ -i content/index.md && rm $<
$(OUTPUT)/index_metadata.yml: $(CONTENT_DIR)/index.md
@./gen-listing-meta.sh $@ 10 $(POSTS_DIR)/*.md
$(OUTPUT)/archive.html: $(OUTPUT)/archive_metadata.yml
@echo "generating archive"
@pandoc \
--standalone \
--css=css/style.css \
--include-before-body=$(TEMPLATE_DIR)/header.html \
--include-after-body=$(TEMPLATE_DIR)/footer.html \
--template=$(TEMPLATE_DIR)/archive.html \
--metadata-file=$< \
-o $@ -i content/archive.md && rm $<
$(OUTPUT)/archive_metadata.yml: $(CONTENT_DIR)/archive.md
@./gen-listing-meta.sh $@ 1000 $(POSTS_DIR)/*.md
$(OUTPUT)/%: content/metadata/%
@cp $< $@
clean:
@rm -r $(OUTPUT)/*
serve:
@docker start snow-dev.com &> /dev/null || \
docker run --name snow-dev.com \
-v $$(pwd)/$(OUTPUT):/usr/share/nginx/html:ro \
-p 8088:80 \
-d nginx
@echo "server started at http://localhost:8088"
install-tools: tools/feed
cd tools/feed && go install ./