Add rss feed
This commit is contained in:
parent
857e0b65ac
commit
46807b2ba6
5 changed files with 119 additions and 9 deletions
18
Makefile
18
Makefile
|
|
@ -17,7 +17,7 @@ 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_rss := $(PANDOCDIR)/rss-template.xml
|
||||
# Template for extracting metadata of .md files in json format
|
||||
list_template := $(PANDOCDIR)/meta-json-template.txt
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ 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
|
||||
all: $(BUILDDIR)/index.html $(BUILDDIR)/index $(BUILDDIR)/rssfeed.xml
|
||||
|
||||
install:
|
||||
cp -r $(BUILDDIR)/index.html $(articles_html) $(STYLEDIR) $(IMAGEDIR) $(INSTALLDIR_HTML); \
|
||||
|
|
@ -48,13 +48,15 @@ $(BUILDDIR):
|
|||
|
||||
$(BUILDDIR)/$(ARTICLEDIR)/%.html: $(SRCDIR)/$(ARTICLEDIR)/%.md | $(BUILDDIR)
|
||||
jq 'del(.articles[] | select(.filename == "$(patsubst %.html,%,$(notdir $@))"))' $(article_list) > articles.json.tmp; \
|
||||
mv ./articles.json.tmp $(article_list); \
|
||||
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 $@))", "pubdate": "$(shell date -d $(shell pandoc $< --template $(list_template) | jq '.date') --rfc-2822)"}')]' $(article_list) > articles.json.tmp; \
|
||||
mv articles.json.tmp $(article_list);
|
||||
|
||||
|
||||
$(BUILDDIR)/$(ARTICLEDIR)/%: $(SRCDIR)/$(ARTICLEDIR)/%.md | $(BUILDDIR)
|
||||
pandoc $< --template $(template_ansi) --to ansi --output $@
|
||||
|
|
@ -62,9 +64,13 @@ $(BUILDDIR)/$(ARTICLEDIR)/%: $(SRCDIR)/$(ARTICLEDIR)/%.md | $(BUILDDIR)
|
|||
$(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}; \
|
||||
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 $@;
|
||||
|
||||
$(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) --to html --output $@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue