diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2021-05-27 21:35:25 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2021-05-27 21:35:25 -0600 |
commit | b37ef5689b6f36fa175e168f227920a230376188 (patch) | |
tree | f41b2a31f49f6d4c41de61d221c0cecd53c72b4d /src | |
parent | 476084674076b8a802cf9272f58da0445f7bef75 (diff) |
add tags inside article footer instead of separate html element
Diffstat (limited to 'src')
-rw-r--r-- | src/pyssg/builder.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/pyssg/builder.py b/src/pyssg/builder.py index 4939bcc..8f7b67c 100644 --- a/src/pyssg/builder.py +++ b/src/pyssg/builder.py @@ -148,6 +148,12 @@ class HTMLBuilder: t_list: list[str] = None if page.tags is not None: t_list = self.__get_tags_formatted(page.tags, t) + # tags formatted as a single string. + tags_formatted: str = ''.join(t_list) + # join list header and footer with all tags list. + tags_formatted = ''.join([t.tags.list_header, + tags_formatted, + t.tags.list_footer]) # common t.header = t.header.replace("$$LANG", page.lang) @@ -171,17 +177,25 @@ class HTMLBuilder: else: t.article.footer = t.article.footer.replace('$$MTIME', '') + # add tags to article list + if t_list is not None: + t.article.footer = t.article.footer.replace('$$TAGS', + tags_formatted) + else: + t.article.footer = t.article.footer.replace('$$TAGS', '') + with open(os.path.join(self.dst, f_name), 'w') as f: f.write(t.header) f.write(t.article.header) f.write(page.html) - if t_list is not None: - f.write(t.tags.list_header) - for tag in t_list: - f.write(tag) - f.write(t.tags.list_footer) + # not required anymore, tags included in article footer + # if t_list is not None: + # f.write(t.tags.list_header) + # for tag in t_list: + # f.write(tag) + # f.write(t.tags.list_footer) f.write(t.article.footer) f.write(t.footer) |