From b37ef5689b6f36fa175e168f227920a230376188 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Thu, 27 May 2021 21:35:25 -0600 Subject: add tags inside article footer instead of separate html element --- ChangeLog | 4 ++++ src/pyssg/builder.py | 24 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 707d387..4daacd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ CHANGES ======= +v0.4.0 +------ + +* fix bug * fix bug * fix bug * add sitemap support 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) -- cgit v1.2.3-70-g09d2