mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-13 18:40:54 +01:00
Fixed linking of blog posts in navigation (temporary hack)
This commit is contained in:
parent
acd47ab98e
commit
3f87fe0f5b
@ -174,10 +174,22 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
page = self.blog.file.page
|
page = self.blog.file.page
|
||||||
self._attach_at(page.parent, page, self.blog)
|
self._attach_at(page.parent, page, self.blog)
|
||||||
|
|
||||||
# Update entrypoint in navigation (also part of the hack above)
|
# Hack: update pages instances in navigation - this can also be removed
|
||||||
self.blog.file.page = self.blog
|
# once an already open pull request is merged - see https://t.ly/9C_Kz
|
||||||
for items in [self._resolve_siblings(self.blog, nav), nav.pages]:
|
for page in [self.blog, *self.blog.posts, *self.blog.views]:
|
||||||
items[items.index(page)] = self.blog
|
assert isinstance(page, Page)
|
||||||
|
|
||||||
|
# Check if the page that we generated is identical to the page that
|
||||||
|
# is associated with the file - if it is, we're good
|
||||||
|
temp = page.file.page
|
||||||
|
if not temp or temp == page:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# If not, MkDocs overwrote our page with a new instance, which we
|
||||||
|
# need to replace with the one we generated
|
||||||
|
page.file.page = page
|
||||||
|
for items in [self._resolve_siblings(page, nav), nav.pages]:
|
||||||
|
items[items.index(temp)] = page
|
||||||
|
|
||||||
# Attach posts to entrypoint without adding them to the navigation, so
|
# Attach posts to entrypoint without adding them to the navigation, so
|
||||||
# that the entrypoint is considered to be the active page for each post
|
# that the entrypoint is considered to be the active page for each post
|
||||||
|
@ -174,10 +174,22 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
page = self.blog.file.page
|
page = self.blog.file.page
|
||||||
self._attach_at(page.parent, page, self.blog)
|
self._attach_at(page.parent, page, self.blog)
|
||||||
|
|
||||||
# Update entrypoint in navigation (also part of the hack above)
|
# Hack: update pages instances in navigation - this can also be removed
|
||||||
self.blog.file.page = self.blog
|
# once an already open pull request is merged - see https://t.ly/9C_Kz
|
||||||
for items in [self._resolve_siblings(self.blog, nav), nav.pages]:
|
for page in [self.blog, *self.blog.posts, *self.blog.views]:
|
||||||
items[items.index(page)] = self.blog
|
assert isinstance(page, Page)
|
||||||
|
|
||||||
|
# Check if the page that we generated is identical to the page that
|
||||||
|
# is associated with the file - if it is, we're good
|
||||||
|
temp = page.file.page
|
||||||
|
if not temp or temp == page:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# If not, MkDocs overwrote our page with a new instance, which we
|
||||||
|
# need to replace with the one we generated
|
||||||
|
page.file.page = page
|
||||||
|
for items in [self._resolve_siblings(page, nav), nav.pages]:
|
||||||
|
items[items.index(temp)] = page
|
||||||
|
|
||||||
# Attach posts to entrypoint without adding them to the navigation, so
|
# Attach posts to entrypoint without adding them to the navigation, so
|
||||||
# that the entrypoint is considered to be the active page for each post
|
# that the entrypoint is considered to be the active page for each post
|
||||||
|
Loading…
Reference in New Issue
Block a user