mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed blog title not being consistent in pagination
This commit is contained in:
@@ -202,7 +202,14 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
if page in self._resolve_views(self.blog):
|
if page in self._resolve_views(self.blog):
|
||||||
assert isinstance(page, View)
|
assert isinstance(page, View)
|
||||||
if 0 < page.pages.index(page):
|
if 0 < page.pages.index(page):
|
||||||
return f"# {page.title}"
|
main = page.parent
|
||||||
|
|
||||||
|
# We need to use the rendered title of the original view
|
||||||
|
# if the author set the title in the page's contents, or
|
||||||
|
# it would be overridden with the one set in mkdocs.yml,
|
||||||
|
# which would result in inconsistent headings
|
||||||
|
name = main._title_from_render or main.title
|
||||||
|
return f"# {name}"
|
||||||
|
|
||||||
# Nothing more to be done for views
|
# Nothing more to be done for views
|
||||||
return
|
return
|
||||||
@@ -614,9 +621,8 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
file.abs_src_path = view.file.abs_src_path
|
file.abs_src_path = view.file.abs_src_path
|
||||||
files.append(file)
|
files.append(file)
|
||||||
|
|
||||||
# Create view and attach to parent - we don't set the title of the
|
# Create view and attach to previous page
|
||||||
# view, so authors can override them in the page's content
|
next = View(view.title, file, config)
|
||||||
next = View(None, file, config)
|
|
||||||
self._attach(prev, [
|
self._attach(prev, [
|
||||||
view.previous_page,
|
view.previous_page,
|
||||||
next,
|
next,
|
||||||
|
|||||||
@@ -202,7 +202,14 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
if page in self._resolve_views(self.blog):
|
if page in self._resolve_views(self.blog):
|
||||||
assert isinstance(page, View)
|
assert isinstance(page, View)
|
||||||
if 0 < page.pages.index(page):
|
if 0 < page.pages.index(page):
|
||||||
return f"# {page.title}"
|
main = page.parent
|
||||||
|
|
||||||
|
# We need to use the rendered title of the original view
|
||||||
|
# if the author set the title in the page's contents, or
|
||||||
|
# it would be overridden with the one set in mkdocs.yml,
|
||||||
|
# which would result in inconsistent headings
|
||||||
|
name = main._title_from_render or main.title
|
||||||
|
return f"# {name}"
|
||||||
|
|
||||||
# Nothing more to be done for views
|
# Nothing more to be done for views
|
||||||
return
|
return
|
||||||
@@ -614,9 +621,8 @@ class BlogPlugin(BasePlugin[BlogConfig]):
|
|||||||
file.abs_src_path = view.file.abs_src_path
|
file.abs_src_path = view.file.abs_src_path
|
||||||
files.append(file)
|
files.append(file)
|
||||||
|
|
||||||
# Create view and attach to parent - we don't set the title of the
|
# Create view and attach to previous page
|
||||||
# view, so authors can override them in the page's content
|
next = View(view.title, file, config)
|
||||||
next = View(None, file, config)
|
|
||||||
self._attach(prev, [
|
self._attach(prev, [
|
||||||
view.previous_page,
|
view.previous_page,
|
||||||
next,
|
next,
|
||||||
|
|||||||
Reference in New Issue
Block a user