1
0
Fork 0

Compare commits

..

2 Commits

7 changed files with 24 additions and 23 deletions

View File

@ -1,23 +1,26 @@
.PHONY: * .PHONY: *
build: help: ## display this help
./build.py out/ --draft @awk 'BEGIN{FS = ":.*##"; printf "\033[1m\nUsage\n \033[1;92m make\033[0;36m <target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST)
build: ## compile src/ into out/ with pagefind
./build.py out/
pagefind --site out/ pagefind --site out/
clean: clean: ## delete out/ and src/
test -e out && rm -rf out || true test -e out && rm -rf out || true
test -e srv && rm -rf srv || true test -e srv && rm -rf srv || true
watch: watch: ## rebuild on changes
while inotifywait -r -e modify -e move -e create -e delete build.py Makefile src/; do make build; done while inotifywait -r -e modify -e move -e create -e delete build.py Makefile src/; do make build; done
serve: serve: ## serve out/
python -m http.server --directory out/ python -m http.server --directory out/
pubdate: pubdate: ## Replace "pubdate: now" with the current date
sed -i "s/pubdate: now/pubdate: $$(date -Isec)/" src/blog/**/*.md sed -i "s/pubdate: now/pubdate: $$(date -Isec)/" src/blog/**/*.md
upload: upload: ## build to srv/ and upload to www.alogoulogoi.com
test -e srv && rm -rf srv || true test -e srv && rm -rf srv || true
./build.py srv/ ./build.py srv/
pagefind --site srv/ pagefind --site srv/

View File

@ -6,16 +6,26 @@ import copy
import os import os
import pathlib import pathlib
import shutil import shutil
import subprocess
import bs4 import bs4
from feedgen.feed import FeedGenerator from feedgen.feed import FeedGenerator
import markdown import markdown
def get_pubdate(src_path):
pubdate = subprocess.run(
["git", "log", "--diff-filter=A", "--format=%aI", "--", src_path],
capture_output=True,
text=True,
check=True,
)
return datetime.fromisoformat(pubdate.stdout.strip())
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("out", help="output directory") parser.add_argument("out", help="output directory")
parser.add_argument("--draft", action="store_true", help="include draft pages")
args = parser.parse_args() args = parser.parse_args()
src = pathlib.Path("src") src = pathlib.Path("src")
@ -124,11 +134,8 @@ def main():
page.header.append(aside) page.header.append(aside)
# RSS metadata # RSS metadata
if "pubdate" in meta and meta["pubdate"][0] == "draft" and not args.draft: if "feed" in meta:
continue pubdate = get_pubdate(path.as_posix())
if "feed" in meta and "pubdate" in meta and meta["pubdate"][0] != "draft":
pubdate = datetime.fromisoformat(meta["pubdate"][0])
link = f"https://www.alogoulogoi.com/{dest.relative_to(out).as_posix()}" link = f"https://www.alogoulogoi.com/{dest.relative_to(out).as_posix()}"
for feed in meta["feed"]: for feed in meta["feed"]:
if feed not in feeds: if feed not in feeds:

View File

@ -23,12 +23,7 @@
pkgs.pagefind pkgs.pagefind
]; ];
shellHook = '' shellHook = ''
echo "make build - compile src/ into out/ with pagefind" make help
echo "make clean - delete out/ and srv/"
echo "make watch - rebuild on changes"
echo "make serve - serve out/"
echo "make pubdate - replace 'now' with the current date"
echo "make upload - build to srv/ and upload to alogoulogoi"
''; '';
}; };
}; };

View File

@ -1,6 +1,5 @@
--- ---
title: The traditional first software engineer blog post title: The traditional first software engineer blog post
pubdate: 2023-09-28T15:39:59-07:00
feed: blog feed: blog
--- ---

View File

@ -1,6 +1,5 @@
--- ---
title: SHLVL PS1 title: SHLVL PS1
pubdate: 2023-12-18T09:53:17-08:00
feed: blog feed: blog
--- ---

View File

@ -1,6 +1,5 @@
--- ---
title: Backing up my ZFS NAS to an external drive title: Backing up my ZFS NAS to an external drive
pubdate: 2023-09-29T16:23:49-07:00
feed: blog feed: blog
--- ---

View File

@ -1,6 +1,5 @@
--- ---
title: Archiving bookmarks title: Archiving bookmarks
pubdate: 2024-05-27T21:06:37-07:00
feed: blog feed: blog
--- ---