slugify stuff

This commit is contained in:
Guy Godfroy 2020-12-04 13:38:35 +01:00
parent 6ffef42c2c
commit 2f28e02dff
1 changed files with 9 additions and 6 deletions

View File

@ -2,6 +2,7 @@
from md2gemini import md2gemini from md2gemini import md2gemini
import frontmatter import frontmatter
from slugify import slugify
from jinja2 import Template from jinja2 import Template
import os import os
import locale import locale
@ -107,14 +108,16 @@ for dirname, subdirlist, mdlist in os.walk('.'):
posts.append(post) posts.append(post)
for tag in post["tags"]: for tag in post["tags"]:
if tag in tags: slugtag = slugify(tag)
tags[tag].append(post) if slugtag in tags:
tags[tag]["posts"].append(post)
else: else:
tags[tag] = [post] tags[tag] = {"name": tag, "posts": [post]}
if post["author"] in authors: slugauthor = slugify(post["author"])
authors[post["author"]].append(post) if slugauthor in authors:
authors[post["author"]]["posts"].append(post)
else: else:
authors[post["author"]] = [post] authors[post["author"]] = {"name": post["author"], "posts": [post]}
# Time to write the GMI file # Time to write the GMI file
with open(gmi_subpath+"/"+gmifile, 'w') as gmi: with open(gmi_subpath+"/"+gmifile, 'w') as gmi: