My tech blog https://blog.neon.moe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
2.0KB

  1. .POSIX:
  2. POSTS = public/2020/04/03/fps-movement.html public/2019/10/27/hidpi.html public/2019/07/15/mastodown.html public/2019/07/06/make.html
  3. POSTS_XML = $(POSTS:.html=.xml)
  4. POSTS_PREVIEW = $(POSTS:.html=.preview.html)
  5. RESOURCES = public/dark.css public/light.css public/feed.xml public/index.html
  6. TEMPLATE_POST_HTML = templates/post.html
  7. TEMPLATE_POST_PREVIEW = templates/post-preview.html
  8. TEMPLATE_INDEX = templates/index.html
  9. TEMPLATE_POST_ATOM = templates/post.xml
  10. TEMPLATE_FEED_ATOM = templates/feed.xml
  11. all: $(POSTS) $(RESOURCES)
  12. clean:
  13. rm $(POSTS) $(POSTS_XML) $(POSTS_PREVIEW) $(RESOURCES)
  14. public/dark.css: public/default.css
  15. sed -e 's/(prefers-color-scheme: light)/not all/g' -e 's/(prefers-color-scheme: dark)/all/g' $? > $@
  16. public/light.css: public/default.css
  17. sed -e 's/(prefers-color-scheme: light)/all/g' -e 's/(prefers-color-scheme: dark)/not all/g' $? > $@
  18. public/feed.xml: $(POSTS_XML)
  19. cat $(POSTS_XML) > $@.tmp
  20. awk -f templater.awk $@.tmp $(TEMPLATE_FEED_ATOM) > $@.tmp.tmp
  21. cat $@.tmp | awk "/<updated>/ { print }" | sort | tail -n 1 | awk -f templater.awk -v REPLACE="{{updated}}" - $@.tmp.tmp > $@
  22. rm $@.tmp $@.tmp.tmp
  23. public/index.html: $(POSTS_PREVIEW) $(TEMPLATE_INDEX)
  24. cat $(POSTS_PREVIEW) | awk -f templater.awk - $(TEMPLATE_INDEX) > $@
  25. # Touching the .md files to trigger re-rendering if the template file or the metadata is changed
  26. $(POSTS:.html=.md): $(TEMPLATE_POST_HTML) $(TEMPLATE_POST_PREVIEW) $(TEMPLATE_INDEX) $(TEMPLATE_POST_ATOM) $(TEMPLATE_FEED_ATOM) $(POSTS:.html=.csv)
  27. touch $@
  28. .SUFFIXES: .html .preview.html .xml .md
  29. .md.html:
  30. cmark --unsafe --smart $< | awk -f templater.awk - $(TEMPLATE_POST_HTML) | awk -f templater.awk -v LOAD_LINES=1 $*.csv - > $@
  31. .md.preview.html:
  32. awk -f templater.awk -v LOAD_LINES=1 $*.csv $(TEMPLATE_POST_PREVIEW) > $@
  33. .md.xml:
  34. cmark --unsafe --smart $< | awk -f templater.awk - $(TEMPLATE_POST_ATOM) | awk -f templater.awk -v LOAD_LINES=1 $*.csv - > $@