sorted by date main feed

This commit is contained in:
veclav talica 2024-02-10 20:58:08 +05:00
parent 952a773875
commit 193ba0b4a5

View File

@ -25,16 +25,23 @@ page = f"""Personal blog of one {choice(ADJECTIVES)} Veclav Talica.
""" """
# todo: Sort by date first. artciles = {}
for root, dirs, _ in walk(argv[1]): for root, dirs, _ in walk(argv[1]):
for d in dirs: for d in dirs:
metadata = parse_metadata(path.abspath(root + '/' + d + "/page.mmd")) metadata = parse_metadata(path.abspath(root + '/' + d + "/page.mmd"))
article = urllib.parse.quote(d) article = urllib.parse.quote(d)
artciles[article] = {
"metadata": metadata
}
break
for title in sorted(artciles.keys(), key=lambda a: artciles[a]["metadata"].get("Date", time.gmtime(0)), reverse=True):
article = artciles[title]
metadata = article["metadata"]
page += ( page += (
f"""[{metadata.get("Title", "No title given! What a clusterfuck!")}](/articles/{article}.html)\n\n""" f"""[{metadata.get("Title", "No title given! What a clusterfuck!")}](/articles/{article}.html)\n\n"""
f""">{metadata.get("Brief", "")}\n\n""" f""">{metadata.get("Brief", "")}\n\n"""
) )
break
curtime = time.gmtime(int(time.time())) curtime = time.gmtime(int(time.time()))
page += f"Last compiled: *{MONTHS[curtime.tm_mon]} {curtime.tm_mday}, {curtime.tm_year} {curtime.tm_hour}:{curtime.tm_min:02d} UTC*\n\n" page += f"Last compiled: *{MONTHS[curtime.tm_mon]} {curtime.tm_mday}, {curtime.tm_year} {curtime.tm_hour}:{curtime.tm_min:02d} UTC*\n\n"