From a6033d1db6da90cca172b1203d792c72c7db9a0c Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 2 Sep 2023 18:13:55 +0200 Subject: [PATCH] Formatting --- material/plugins/blog/plugin.py | 20 ++++++++++---------- src/plugins/blog/plugin.py | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/material/plugins/blog/plugin.py b/material/plugins/blog/plugin.py index ea4a65295b2..08079108e3c 100644 --- a/material/plugins/blog/plugin.py +++ b/material/plugins/blog/plugin.py @@ -235,7 +235,7 @@ def on_page_markdown(self, markdown, *, page, config, files): # We set the contents of the view to its title if pagination should # not keep the content of the original view on paginaged views if not self.config.pagination_keep_content: - view = self._resolve_canonical(page) + view = self._resolve_original(page) if view in self._resolve_views(self.blog): assert isinstance(page, View) if page.pages.index(page): @@ -324,7 +324,7 @@ def on_page_context(self, context, *, page, config, nav): # Skip if page is not a view managed by this instance - this plugin has # support for multiple instances, which is why this check is necessary - view = self._resolve_canonical(page) + view = self._resolve_original(page) if view not in self._resolve_views(self.blog): return @@ -514,13 +514,6 @@ def _resolve_views(self, view: View): assert isinstance(next, View) yield next - # Resolve canonical page of a page, which might be a view - def _resolve_canonical(self, page: Page): - if isinstance(page, View): - return page.pages[0] - else: - return page - # Resolve siblings of a navigation item def _resolve_siblings(self, item: StructureItem, nav: Navigation): if isinstance(item.parent, Section): @@ -528,6 +521,13 @@ def _resolve_siblings(self, item: StructureItem, nav: Navigation): else: return nav.items + # Resolve original page or view (e.g. for paginated views) + def _resolve_original(self, page: Page): + if isinstance(page, View): + return page.pages[0] + else: + return page + # ------------------------------------------------------------------------- # Generate views for archive - analyze posts and generate the necessary @@ -641,7 +641,7 @@ def _attach(self, parent: StructureItem, pages: list[Page]): # If the page is a view, we know that we generated it and need to # link its siblings back to the view if isinstance(page, View): - view = self._resolve_canonical(page) + view = self._resolve_original(page) if tail: tail.next_page = view if head: head.previous_page = view diff --git a/src/plugins/blog/plugin.py b/src/plugins/blog/plugin.py index ea4a65295b2..08079108e3c 100644 --- a/src/plugins/blog/plugin.py +++ b/src/plugins/blog/plugin.py @@ -235,7 +235,7 @@ def on_page_markdown(self, markdown, *, page, config, files): # We set the contents of the view to its title if pagination should # not keep the content of the original view on paginaged views if not self.config.pagination_keep_content: - view = self._resolve_canonical(page) + view = self._resolve_original(page) if view in self._resolve_views(self.blog): assert isinstance(page, View) if page.pages.index(page): @@ -324,7 +324,7 @@ def on_page_context(self, context, *, page, config, nav): # Skip if page is not a view managed by this instance - this plugin has # support for multiple instances, which is why this check is necessary - view = self._resolve_canonical(page) + view = self._resolve_original(page) if view not in self._resolve_views(self.blog): return @@ -514,13 +514,6 @@ def _resolve_views(self, view: View): assert isinstance(next, View) yield next - # Resolve canonical page of a page, which might be a view - def _resolve_canonical(self, page: Page): - if isinstance(page, View): - return page.pages[0] - else: - return page - # Resolve siblings of a navigation item def _resolve_siblings(self, item: StructureItem, nav: Navigation): if isinstance(item.parent, Section): @@ -528,6 +521,13 @@ def _resolve_siblings(self, item: StructureItem, nav: Navigation): else: return nav.items + # Resolve original page or view (e.g. for paginated views) + def _resolve_original(self, page: Page): + if isinstance(page, View): + return page.pages[0] + else: + return page + # ------------------------------------------------------------------------- # Generate views for archive - analyze posts and generate the necessary @@ -641,7 +641,7 @@ def _attach(self, parent: StructureItem, pages: list[Page]): # If the page is a view, we know that we generated it and need to # link its siblings back to the view if isinstance(page, View): - view = self._resolve_canonical(page) + view = self._resolve_original(page) if tail: tail.next_page = view if head: head.previous_page = view