-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (38 loc) · 955 Bytes
/
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
export POST_ROOT := posts
export DATE := $(shell date '+%Y-%m-%d')
MARKDOWN := $(wildcard $(POST_ROOT)/**/*.md)
TITLE = $(error TITLE is not defined)
FILE = $(error FILE is not defined)
SLUG = $(shell ./blog -slugify "$(TITLE)")
.PHONY: all
all: README.md rss.xml
blog: *.go go.* vendor
go build -v
README.md: blog $(MARKDOWN)
./blog > README.md
rss.xml: blog $(MARKDOWN)
./blog -rss > rss.xml
.PHONY: publish
publish: blog
./blog -publish
.PHONY: day
day:
mkdir -p '$(POST_ROOT)/$(DATE)'
.PHONY: post
post: blog day
$(EDITOR) $(shell SLUG=$(SLUG) ./.scripts/gen-post.sh)
.PHONY: draft
draft:
cd '$(dir $(FILE))' && mv '$(notdir $(FILE))' '.$(notdir $(FILE))'
.PHONY: undraft
undraft:
cd '$(dir $(FILE))' && mv '$(notdir $(FILE))' '$(patsubst .%,%,$(notdir $(FILE)))'
.PHONY: image
image:
@echo '[![$(DESCRIPTION)](/$(POST_ROOT)/$(FILE))](/$(FILE))'
.PHONY: words
words:
wc -w $(POST_ROOT)/**/*.md
.PHONY: clean
clean:
rm -rf blog