From 978a7dad46a07c4d00ae9fe5d291cd55b17dc12d Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 21 Apr 2022 19:15:10 +0300 Subject: feat: add blog preview feature --- Makefile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9f21e63..77cfb42 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ RSS_ITEM_TEMPLATE=templates/rss_item.xml EMOJI_SIZE=20 EMOJI_STYLE=margin-bottom: -4px; +BLOG_PREVIEW_MARKER=Recent blog posts + RSS=out/blog/index.xml OPENRING_FOOTER=tmp/openring.html @@ -47,14 +49,28 @@ tmp/%.content.html: src/%.md tmp/emoji.sed @mkdir -p $(@D) sed -e "s/.md)/.html)/g" -f tmp/emoji.sed $< | $(CONVERT) > $@ +out/index.html: tmp/index.content.html $(PAGE_TEMPLATE) + @mkdir -p $(@D) + sed "/<\/main>/e cat $<" $(PAGE_TEMPLATE) > $@ + sed -i \ + -e '//{' \ + -e 'a $(WEBSITE_TITLE)<\/title>' \ + -e '}' $@ + +tmp/index.content.html: src/index.md tmp/emoji.sed tmp/blog/preview.md + @mkdir -p $(@D) + sed -e "/$(BLOG_PREVIEW_MARKER)/r tmp/blog/preview.md" $< \ + | sed -e "s/.md)/.html)/g" -f tmp/emoji.sed \ + | $(CONVERT) > $@ + tmp/%.meta.title: src/%.md @mkdir -p $(@D) sed '/^#/q' $< | sed 's/#* //' > $@ @echo "| $(WEBSITE_TITLE)" >> $@ -tmp/index.meta.title: +tmp/blog/preview.md: src/blog/index.md @mkdir -p $(@D) - echo $(WEBSITE_TITLE) > $@ + sed -n "s/^-/ -/; s|(|(blog/| ; /^ -/p" $< | head -n 4 > $@ $(RSS): $(BLOG_XML) $(RSS_TEMPLATE) @mkdir -p $(@D) -- cgit v1.2.3