This commit is contained in:
Never Gude 2026-02-12 04:10:35 +01:00
parent dddf6082c7
commit 3ca1685ec6
22 changed files with 108 additions and 77 deletions

View file

@ -15,11 +15,11 @@ IMAGEDIR := images
style := $(STYLEDIR)/style.css
# Main html template that pandoc uses to generate .html from .md files
template_html := $(PANDOCDIR)/template.html
template_ansi := $(PANDOCDIR)/template
template_html := $(PANDOCDIR)/html-template.html
template_ansi := $(PANDOCDIR)/ansi-template
template_rss := $(PANDOCDIR)/rss-template.xml
# Template for extracting metadata of .md files in json format
list_template := $(PANDOCDIR)/meta-json-template.txt
list_template := $(PANDOCDIR)/metadata-template.json
# Location of the shark.js
shark_js := $(PANDOCDIR)/shark.js
@ -33,10 +33,10 @@ articles_md := $(wildcard $(SRCDIR)/$(ARTICLEDIR)/*.md)
articles_html := $(patsubst $(SRCDIR)/%.md, $(BUILDDIR)/%.html, $(articles_md))
articles_ansi := $(patsubst $(SRCDIR)/%.md, $(BUILDDIR)/%, $(articles_md))
all: $(BUILDDIR)/index.html $(BUILDDIR)/index $(BUILDDIR)/rssfeed.xml
all: $(BUILDDIR)/index.html $(BUILDDIR)/index $(BUILDDIR)/rss.xml
install:
cp -r $(BUILDDIR)/index.html $(BUILDDIR)/rssfeed.xml $(articles_html) $(STYLEDIR) $(IMAGEDIR) $(INSTALLDIR_HTML); \
cp -r $(BUILDDIR)/index.html $(BUILDDIR)/rss.xml $(articles_html) $(STYLEDIR) $(IMAGEDIR) $(INSTALLDIR_HTML); \
cp -r $(BUILDDIR)/index $(articles_ansi) $(INSTALLDIR_ANSI);
clean:
@ -53,7 +53,6 @@ $(BUILDDIR)/$(ARTICLEDIR)/%.html: $(SRCDIR)/$(ARTICLEDIR)/%.md | $(BUILDDIR)
pandoc $< --template $(template_html) --css $(style) --highlight-style zenburn --mathml --toc --output $@; \
# Extract metadata from .md file, append filename field to the article object.
# This is used to link to the article from index.html. Append article object to the article list.
jq '.articles += [$(shell pandoc $< --template $(list_template) | jq '. += {"filename": "$(patsubst %.html,%,$(notdir $@))", "pubdate": "$(shell date -d $(shell pandoc $< --template $(list_template) | jq '.date') --rfc-2822)"}')]' $(article_list) > articles.json.tmp; \
mv articles.json.tmp $(article_list);
@ -71,5 +70,5 @@ $(BUILDDIR)/index.html: $(SRCDIR)/index.md $(articles_html) | $(BUILDDIR)
$(BUILDDIR)/index: $(SRCDIR)/index.md $(articles_ansi) | $(BUILDDIR)
pandoc $< --template $(template_ansi) --metadata-file $(article_list) --to ansi --output $@
$(BUILDDIR)/rssfeed.xml: $(SRCDIR)/rssfeed.md $(articles_html) | $(BUILDDIR)
pandoc $< --template $(template_rss) --metadata-file $(article_list) --metadata=builddate:"$(shell date --rfc-2822)" --to html --output $@
$(BUILDDIR)/rss.xml: $(SRCDIR)/rss.md $(articles_html) | $(BUILDDIR)
pandoc $< --template $(template_rss) --metadata-file $(article_list) --metadata=pubdate:"$(shell jq -r '.articles[0] | .pubdate' $(article_list))" --metadata=builddate:"$(shell date --rfc-2822)" --to html --output $@