diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2021-06-06 11:38:23 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2021-06-06 11:38:23 -0600 |
commit | 0bdbc47c335f51d36cf869115e8884ccd6a9eaaf (patch) | |
tree | 22153e1da7f1f2d89cab429cd67ea9efeced8e2c | |
parent | fe51b8a45b8648f9ae763b525c59ff27d8d78eaf (diff) |
fix bug on prev/next objects of page
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/pyssg/parser.py | 19 |
2 files changed, 16 insertions, 9 deletions
@@ -1,6 +1,12 @@ CHANGES ======= +v0.5.6 +------ + +* add config to read first pyssgrc and then to the xdg directory +* fix bug on image\_url + v0.5.5 ------ diff --git a/src/pyssg/parser.py b/src/pyssg/parser.py index d75c923..f2d23eb 100644 --- a/src/pyssg/parser.py +++ b/src/pyssg/parser.py @@ -67,14 +67,15 @@ class MDParser: self.all_tags.sort(key=itemgetter(0)) self.updated_pages.sort(reverse=True) self.all_pages.sort(reverse=True) - # TODO: fix this in case it doesn't work lol - for i, p in enumerate(self.all_pages): - try: - prev_page: Page = self.all_pages[i - 1] - p.previous = prev_page - except IndexError: pass - try: - next_page: Page = self.all_pages[i + 1] + pages_amount: int = len(self.all_pages) + # note that prev and next are switched because of the reverse rodering + # of all_pages + for i, p in enumerate(self.all_pages): + if i != 0: + next_page: Page = self.all_pages[i - 1] p.next = next_page - except IndexError: pass + + if i != pages_amount - 1: + prev_page: Page = self.all_pages[i + 1] + p.previous = prev_page |