mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed footer links for blog sibling pages
This commit is contained in:
parent
502c9cae90
commit
6e1c658a9d
@ -235,7 +235,7 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
# We set the contents of the view to its title if pagination should
|
# We set the contents of the view to its title if pagination should
|
||||||
# not keep the content of the original view on paginaged views
|
# not keep the content of the original view on paginaged views
|
||||||
if not self.config.pagination_keep_content:
|
if not self.config.pagination_keep_content:
|
||||||
view = page.pages[0] if isinstance(page, View) else page
|
view = self._resolve_canonical(page)
|
||||||
if view in self._resolve_views(self.blog):
|
if view in self._resolve_views(self.blog):
|
||||||
assert isinstance(page, View)
|
assert isinstance(page, View)
|
||||||
if page.pages.index(page):
|
if page.pages.index(page):
|
||||||
@ -324,7 +324,7 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
|
|
||||||
# Skip if page is not a view managed by this instance - this plugin has
|
# 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
|
# support for multiple instances, which is why this check is necessary
|
||||||
view = page.pages[0] if isinstance(page, View) else page
|
view = self._resolve_canonical(page)
|
||||||
if view not in self._resolve_views(self.blog):
|
if view not in self._resolve_views(self.blog):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -514,6 +514,13 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
assert isinstance(next, View)
|
assert isinstance(next, View)
|
||||||
yield next
|
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
|
# Resolve siblings of a navigation item
|
||||||
def _resolve_siblings(self, item: StructureItem, nav: Navigation):
|
def _resolve_siblings(self, item: StructureItem, nav: Navigation):
|
||||||
if isinstance(item.parent, Section):
|
if isinstance(item.parent, Section):
|
||||||
@ -631,6 +638,13 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
page.previous_page = tail
|
page.previous_page = tail
|
||||||
page.next_page = head
|
page.next_page = head
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
if tail: tail.next_page = view
|
||||||
|
if head: head.previous_page = view
|
||||||
|
|
||||||
# Attach a page to the given parent and link it to the previous and next
|
# Attach a page to the given parent and link it to the previous and next
|
||||||
# page of the given host - this is exclusively used for paginated views
|
# page of the given host - this is exclusively used for paginated views
|
||||||
def _attach_at(self, parent: StructureItem, host: Page, page: Page):
|
def _attach_at(self, parent: StructureItem, host: Page, page: Page):
|
||||||
|
@ -235,7 +235,7 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
# We set the contents of the view to its title if pagination should
|
# We set the contents of the view to its title if pagination should
|
||||||
# not keep the content of the original view on paginaged views
|
# not keep the content of the original view on paginaged views
|
||||||
if not self.config.pagination_keep_content:
|
if not self.config.pagination_keep_content:
|
||||||
view = page.pages[0] if isinstance(page, View) else page
|
view = self._resolve_canonical(page)
|
||||||
if view in self._resolve_views(self.blog):
|
if view in self._resolve_views(self.blog):
|
||||||
assert isinstance(page, View)
|
assert isinstance(page, View)
|
||||||
if page.pages.index(page):
|
if page.pages.index(page):
|
||||||
@ -324,7 +324,7 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
|
|
||||||
# Skip if page is not a view managed by this instance - this plugin has
|
# 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
|
# support for multiple instances, which is why this check is necessary
|
||||||
view = page.pages[0] if isinstance(page, View) else page
|
view = self._resolve_canonical(page)
|
||||||
if view not in self._resolve_views(self.blog):
|
if view not in self._resolve_views(self.blog):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -514,6 +514,13 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
assert isinstance(next, View)
|
assert isinstance(next, View)
|
||||||
yield next
|
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
|
# Resolve siblings of a navigation item
|
||||||
def _resolve_siblings(self, item: StructureItem, nav: Navigation):
|
def _resolve_siblings(self, item: StructureItem, nav: Navigation):
|
||||||
if isinstance(item.parent, Section):
|
if isinstance(item.parent, Section):
|
||||||
@ -631,6 +638,13 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
page.previous_page = tail
|
page.previous_page = tail
|
||||||
page.next_page = head
|
page.next_page = head
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
if tail: tail.next_page = view
|
||||||
|
if head: head.previous_page = view
|
||||||
|
|
||||||
# Attach a page to the given parent and link it to the previous and next
|
# Attach a page to the given parent and link it to the previous and next
|
||||||
# page of the given host - this is exclusively used for paginated views
|
# page of the given host - this is exclusively used for paginated views
|
||||||
def _attach_at(self, parent: StructureItem, host: Page, page: Page):
|
def _attach_at(self, parent: StructureItem, host: Page, page: Page):
|
||||||
|
Loading…
Reference in New Issue
Block a user