@@ -3,17 +3,22 @@ SITE_TITLE := Neotokyo; Rebuild
33
44SRC_DIR := src
55DST_DIR := _out
6- SRCS := $(shell find $(SRC_DIR ) -name '* .md')
6+ SRCS := $(shell find $(SRC_DIR ) -name '* .md' | grep -vxF "src/index.md" )
77SRCS_CPY := $(SRC_DIR ) /style.css
88
9- BLOG_LIST_FILE := $( DST_DIR ) /blog_list
9+ BLOG_LIST_FILE := _metadata /blog_list
1010DSTS_HTML := $(SRCS:$(SRC_DIR ) /%.md=$(DST_DIR ) /%.html )
1111DSTS_HTML_CPY := $(SRCS_CPY:$(SRC_DIR ) /%=$(DST_DIR ) /% )
1212
1313all : html
1414
15+ startup :
16+ mkdir -p _out
17+ mkdir -p _metadata
18+
1519clean :
1620 rm -fr $(DST_DIR )
21+ rm -fr _metadata
1722
1823serve :
1924 python3 -m http.server -d $(DST_DIR )
@@ -36,32 +41,34 @@ $(DST_DIR)/%: $(SRC_DIR)/%
3641 @mkdir -p $(dir $@ )
3742 @cp $< $@
3843
39- $(DST_DIR ) /blog/ index.html : $(SRC_DIR ) /blog/* /* .md $(SRC_DIR ) /_header.html $(SRC_DIR ) /_footer.html
44+ $(DST_DIR ) /index.html : $(SRC_DIR ) /blog/* /* .md $(SRC_DIR ) /_header.html $(SRC_DIR ) /_footer.html
4045 @echo " html (blog):" $@
41- @echo " <h1>Blog</h1><ul>" > $@ .mid
4246 @mv $(BLOG_LIST_FILE ) $(BLOG_LIST_FILE ) .tmp
4347 @cat $(BLOG_LIST_FILE ) .tmp | sort -ur > $(BLOG_LIST_FILE )
4448 @rm $(BLOG_LIST_FILE ) .tmp
49+ @SSG_TITLE=$$(lowdown -X title $< ) ; \
50+ m4 -DSSG_TITLE=" $$ SSG_TITLE" $(SRC_DIR ) /_header.html > $@ .header.html.tmp
51+ @lowdown -Thtml -o $@ .tmp < $(SRC_DIR ) /index.md
52+ @echo " <ul>" >> $@ .mid
4553 @cat $(BLOG_LIST_FILE ) | while read line; do \
4654 entry_date=$$(echo "$$line" | cut -f1 ) ; \
4755 title=$$(echo "$$line" | cut -f2 ) ; \
48- echo " <li><a href=\" $$ entry_date\" >$$ entry_date - $$ title</a></li>" ; \
56+ echo " <li><a href=\" /blog/ $$ entry_date\" >$$ entry_date - $$ title</a></li>" ; \
4957 done >> $@ .mid
5058 @echo " </ul>" >> $@ .mid
51- @m4 -DSSG_TITLE=" Blog" $(SRC_DIR ) /_header.html > $@ .header
52- @cat $@ .header $@ .mid $(SRC_DIR ) /_footer.html > $@
53- @rm $@ .header $@ .mid
59+ @cat $@ .header.html.tmp $@ .tmp $@ .mid $(SRC_DIR ) /_footer.html > $@
60+ @rm $@ .tmp $@ .header.html.tmp $@ .mid
5461
55- $(DST_DIR ) /blog/ atom.xml : $(SRC_DIR ) /blog/* /* .md
62+ $(DST_DIR ) /atom.xml : $(SRC_DIR ) /blog/* /* .md
5663 @echo " html (atom):" $@
5764 @echo " <?xml version=\" 1.0\" encoding=\" utf-8\" ?>" > $@
5865 @echo " <feed xmlns=\" http://www.w3.org/2005/Atom\" >" >> $@
5966 @echo " <title type=\" text\" >$( SITE_TITLE) </title>" >> $@
6067 @echo " <updated>$$ (head -n1 " $(BLOG_LIST_FILE ) " | cut -f1)T00:00:00Z</updated>" >> $@
6168 @echo " <id>$( SITE_HTTPS_URL) blog/</id>" >> $@
6269 @echo " <author><name>$( SITE_TITLE) </name></author>" >> $@
63- @echo " <link rel=\" alternate\" type=\" text/html\" href=\" $( SITE_HTTPS_URL) blog/ \" />" >> $@
64- @echo " <link rel=\" self\" type=\" application/atom+xml\" href=\" $( SITE_HTTPS_URL) blog/ atom.xml\" />" >> $@
70+ @echo " <link rel=\" alternate\" type=\" text/html\" href=\" $( SITE_HTTPS_URL) \" />" >> $@
71+ @echo " <link rel=\" self\" type=\" application/atom+xml\" href=\" $( SITE_HTTPS_URL) atom.xml\" />" >> $@
6572 @cat $(BLOG_LIST_FILE ) | while read line; do \
6673 entry_date=$$(echo "$$line" | cut -f1 ) ; \
6774 title=$$(echo "$$line" | cut -f2 ) ; \
@@ -77,7 +84,7 @@ $(DST_DIR)/blog/atom.xml: $(SRC_DIR)/blog/*/*.md
7784 done >> $@
7885 @echo " </feed>" >> $@
7986
80- html : $(DSTS_HTML ) $(DSTS_HTML_CPY ) # $(DST_DIR)/blog/ index.html $(DST_DIR)/blog /atom.xml
87+ html : startup $(DSTS_HTML ) $(DSTS_HTML_CPY ) $(DST_DIR ) /index.html $(DST_DIR ) /atom.xml
8188
8289.PHONY : all clean html
8390
0 commit comments