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. # disabled.
# #
# Exemple: if the property is tags, then it will generate a tag index tags.gmi, # 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). # an existing tag).
# #
# Specify here a list of dictionnary, each one with the following keys: # 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 # Parse the YAML header
meta = frontmatter.parse(mdtext)[0] meta = frontmatter.parse(mdtext)[0]
# Extract useful informations from the header # Extract post properties
post["template"] = meta.get("template", None) for prop in config.post_props:
post["author"] = meta.get("author", None) post[prop] = meta.get(prop, None)
post["date"] = meta.get("date", None)
post["title"] = meta.get("title", None) # Extract index properties
post["tags"] = meta.get("tags", None).split(',') 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 # For now, tags list must be a comma-separated string
# TODO: make possible to list tags as a YAML list # TODO: make possible to list tags as a YAML list