Skip to content

Commit 438aae6

Browse files
committed
Limit atom and news.txt feeds to 5 latest entries
1 parent 335a4dd commit 438aae6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ BLOG_DATES := _metadata/blog_dates
1111
DSTS_HTML := $(SRCS:$(SRC_DIR)/%.md=$(DST_DIR)/%.html)
1212
DSTS_HTML_CPY := $(SRCS_CPY:$(SRC_DIR)/%=$(DST_DIR)/%)
1313

14+
FEEDS_LIMIT := 5
15+
1416
all: html
1517

1618
startup:
@@ -76,7 +78,7 @@ $(DST_DIR)/atom.xml: $(SRC_DIR)/blog/*/*.md
7678
@echo "<author><name>$(SITE_TITLE)</name></author>" >> $@
7779
@echo "<link rel=\"alternate\" type=\"text/html\" href=\"$(SITE_HTTPS_URL)\"/>" >> $@
7880
@echo "<link rel=\"self\" type=\"application/atom+xml\" href=\"$(SITE_HTTPS_URL)atom.xml\"/>" >> $@
79-
@cat $(BLOG_LIST_FILE) | while read line; do \
81+
@cat $(BLOG_LIST_FILE) | head -n$(FEEDS_LIMIT) | while read line; do \
8082
entry_date=$$(echo "$$line" | cut -f1); \
8183
title=$$(echo "$$line" | cut -f2); \
8284
entry_url=$$(echo "$(SITE_HTTPS_URL)blog/$$entry_date/"); \
@@ -97,7 +99,7 @@ $(DST_DIR)/atom.xml: $(SRC_DIR)/blog/*/*.md
9799
news_txt:
98100
@echo "_out/news.txt"
99101
@cat $(BLOG_LIST_FILE) | cut -f1 > $(BLOG_DATES)
100-
@paste $(BLOG_DATES) $(BLOG_LIST_FILE) | sed -e 's/^/\/blog\//' > "$(DST_DIR)/news.txt"
102+
@paste $(BLOG_DATES) $(BLOG_LIST_FILE) | sed -e 's/^/\/blog\//' | head -n$(FEEDS_LIMIT) > "$(DST_DIR)/news.txt"
101103

102104
html: startup $(DSTS_HTML) $(DSTS_HTML_CPY) $(DST_DIR)/index.html $(DST_DIR)/atom.xml news_txt
103105

0 commit comments

Comments
 (0)