sort articles by date

This commit is contained in:
Never Gude 2026-02-11 22:20:11 +01:00
parent d2389e00ed
commit 857e0b65ac
25 changed files with 89 additions and 278 deletions

View file

@ -47,23 +47,24 @@ $(BUILDDIR):
mkdir $(BUILDDIR) $(BUILDDIR)/$(ARTICLEDIR)
$(BUILDDIR)/$(ARTICLEDIR)/%.html: $(SRCDIR)/$(ARTICLEDIR)/%.md | $(BUILDDIR)
jq 'del(.articles[] | select(.filename == "$(notdir $@)"))' $(article_list) > articles.json.tmp; \
jq 'del(.articles[] | select(.filename == "$(patsubst %.html,%,$(notdir $@))"))' $(article_list) > articles.json.tmp; \
mv ./articles.json.tmp $(article_list); \
# Build articles using pandoc
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 $@))"}')]' $(article_list) > articles.json.tmp; \
mv ./articles.json.tmp $(article_list); \
jq '.articles += [$(shell pandoc $< --template $(list_template) | jq '. += {"filename": "$(patsubst %.html,%,$(notdir $@))"}')]' $(article_list) > articles.json.tmp; \
mv ./articles.json.tmp $(article_list);
$(BUILDDIR)/$(ARTICLEDIR)/%: $(SRCDIR)/$(ARTICLEDIR)/%.md | $(BUILDDIR)
pandoc $< --template $(template_ansi) --to ansi --output $@
$(BUILDDIR)/index.html: $(SRCDIR)/index.md $(articles_html) | $(BUILDDIR)
# Sort articles decending by date (date need to be in ISO 8601 format)
jq '.articles |= sort_by(.date) | .articles |= reverse' ${article_list} > articles.json.tmp; \
mv ./articles.json.tmp ${article_list}; \
# Build index.html with metadata injected from articles_list
pandoc $< --template $(template_html) --include-after-body $(shark_js) --css $(style) --metadata-file $(article_list) --highlight-style zenburn --mathml --toc --output $@; \
pandoc $< --template $(template_html) --include-after-body $(shark_js) --css $(style) --metadata-file $(article_list) --highlight-style zenburn --mathml --toc --output $@;
$(BUILDDIR)/index: $(SRCDIR)/index.md $(articles_ansi) | $(BUILDDIR)
pandoc $< --template $(template_ansi) --metadata-file $(article_list) --to ansi --output $@