make meta properties configurable

This commit is contained in:
Guy Godfroy 2020-12-04 17:07:57 +01:00
parent a62db1fc2b
commit e2edf189fc
2 changed files with 12 additions and 7 deletions

View File

@ -79,7 +79,7 @@ post_props = [
# disabled.
#
# Exemple: if the property is tags, then it will generate a tag index tags.gmi,
# which will ling to some subindexes like tags/computer (assuming computer is
# which will link to some subindexes like tags/computer (assuming computer is
# an existing tag).
#
# Specify here a list of dictionnary, each one with the following keys:

View File

@ -68,12 +68,17 @@ for dirname, subdirlist, mdlist in os.walk('.'):
# Parse the YAML header
meta = frontmatter.parse(mdtext)[0]
# Extract useful informations from the header
post["template"] = meta.get("template", None)
post["author"] = meta.get("author", None)
post["date"] = meta.get("date", None)
post["title"] = meta.get("title", None)
post["tags"] = meta.get("tags", None).split(',')
# Extract post properties
for prop in config.post_props:
post[prop] = meta.get(prop, None)
# Extract index properties
for prop_dict in config.index_props:
prop = prop_dict["property"]
post[prop] = meta.get(prop, None)
if prop_dict.get("list", False) and post[prop]:
post[prop] = post[prop].split(',')
# For now, tags list must be a comma-separated string
# TODO: make possible to list tags as a YAML list