frontmatter fix about 'created' field
This commit is contained in:
parent
185373699b
commit
c5cdcc42f8
|
@ -9,6 +9,7 @@ import sys
|
|||
import configparser
|
||||
from fnmatch import fnmatch
|
||||
import frontmatter # from package python-frontmatter
|
||||
import datetime
|
||||
|
||||
def link_this(src: str, dest: str):
|
||||
"""Creates symlink to source at destination
|
||||
|
@ -109,7 +110,14 @@ if __name__ == '__main__':
|
|||
|
||||
# load content file
|
||||
with open('content/'+path) as fp:
|
||||
content_data = fp.read()
|
||||
frontmatter_data, content = frontmatter.parse(fp.read())
|
||||
|
||||
if 'created' in frontmatter_data:
|
||||
# frontmatter produces date objects if created field is in format yyyy-mm-dd
|
||||
# if it contains time as in ISO 8601, we want to convert it to datetime
|
||||
# https://en.wikipedia.org/wiki/ISO_8601
|
||||
if type(frontmatter_data['created']) == str:
|
||||
frontmatter_data['created'] = datetime.datetime.fromisoformat(frontmatter_data['created'])
|
||||
|
||||
# load template
|
||||
if template := template_for(path):
|
||||
|
|
Reference in New Issue