Derive blog post pubdate from git instead of metadata
This commit is contained in:
parent
8935d6f3a9
commit
1a7c02ca64
2
Makefile
2
Makefile
@ -4,7 +4,7 @@ help: ## display this help
|
||||
@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/ --draft
|
||||
./build.py out/
|
||||
pagefind --site out/
|
||||
|
||||
clean: ## delete out/ and src/
|
||||
|
19
build.py
19
build.py
@ -6,16 +6,26 @@ import copy
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
import bs4
|
||||
from feedgen.feed import FeedGenerator
|
||||
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():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("out", help="output directory")
|
||||
parser.add_argument("--draft", action="store_true", help="include draft pages")
|
||||
args = parser.parse_args()
|
||||
|
||||
src = pathlib.Path("src")
|
||||
@ -124,11 +134,8 @@ def main():
|
||||
page.header.append(aside)
|
||||
|
||||
# RSS metadata
|
||||
if "pubdate" in meta and meta["pubdate"][0] == "draft" and not args.draft:
|
||||
continue
|
||||
|
||||
if "feed" in meta and "pubdate" in meta and meta["pubdate"][0] != "draft":
|
||||
pubdate = datetime.fromisoformat(meta["pubdate"][0])
|
||||
if "feed" in meta:
|
||||
pubdate = get_pubdate(path.as_posix())
|
||||
link = f"https://www.alogoulogoi.com/{dest.relative_to(out).as_posix()}"
|
||||
for feed in meta["feed"]:
|
||||
if feed not in feeds:
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
title: The traditional first software engineer blog post
|
||||
pubdate: 2023-09-28T15:39:59-07:00
|
||||
feed: blog
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
title: SHLVL PS1
|
||||
pubdate: 2023-12-18T09:53:17-08:00
|
||||
feed: blog
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
title: Backing up my ZFS NAS to an external drive
|
||||
pubdate: 2023-09-29T16:23:49-07:00
|
||||
feed: blog
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
---
|
||||
title: Archiving bookmarks
|
||||
pubdate: 2024-05-27T21:06:37-07:00
|
||||
feed: blog
|
||||
---
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user