Fixed further regression in blog plugin navigation

This commit is contained in:
squidfunk 2023-09-04 14:06:51 +02:00
parent 5e42517a22
commit fc566cf0e2
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
2 changed files with 8 additions and 10 deletions

View File

@ -34,7 +34,7 @@ from mkdocs.structure import StructureItem
from mkdocs.structure.files import File, Files, InclusionLevel from mkdocs.structure.files import File, Files, InclusionLevel
from mkdocs.structure.nav import Navigation, Section from mkdocs.structure.nav import Navigation, Section
from mkdocs.structure.pages import Page from mkdocs.structure.pages import Page
from mkdocs.utils import get_relative_url from mkdocs.utils import copy_file, get_relative_url
from paginate import Page as Pagination from paginate import Page as Pagination
from shutil import rmtree from shutil import rmtree
from tempfile import mkdtemp from tempfile import mkdtemp
@ -225,10 +225,6 @@ class BlogPlugin(BasePlugin[BlogConfig]):
for at in range(1, len(view.pages)): for at in range(1, len(view.pages)):
self._attach_at(view.parent, view, view.pages[at]) self._attach_at(view.parent, view, view.pages[at])
# Replace source file system path
view.pages[at].file.src_uri = view.file.src_uri
view.pages[at].file.abs_src_path = view.file.abs_src_path
# Prepare post for rendering (run later) - allow other plugins to alter # Prepare post for rendering (run later) - allow other plugins to alter
# the contents or metadata of a post before it is rendered and make sure # the contents or metadata of a post before it is rendered and make sure
# that the post includes a separator, which is essential for rendering # that the post includes a separator, which is essential for rendering
@ -640,6 +636,9 @@ class BlogPlugin(BasePlugin[BlogConfig]):
file = self._path_to_file(path, config) file = self._path_to_file(path, config)
files.append(file) files.append(file)
# Copy file to temporary directory
copy_file(view.file.abs_src_path, file.abs_src_path)
# Create view and attach to previous page # Create view and attach to previous page
if not isinstance(file.page, View): if not isinstance(file.page, View):
yield View(None, file, config) yield View(None, file, config)

View File

@ -34,7 +34,7 @@ from mkdocs.structure import StructureItem
from mkdocs.structure.files import File, Files, InclusionLevel from mkdocs.structure.files import File, Files, InclusionLevel
from mkdocs.structure.nav import Navigation, Section from mkdocs.structure.nav import Navigation, Section
from mkdocs.structure.pages import Page from mkdocs.structure.pages import Page
from mkdocs.utils import get_relative_url from mkdocs.utils import copy_file, get_relative_url
from paginate import Page as Pagination from paginate import Page as Pagination
from shutil import rmtree from shutil import rmtree
from tempfile import mkdtemp from tempfile import mkdtemp
@ -225,10 +225,6 @@ class BlogPlugin(BasePlugin[BlogConfig]):
for at in range(1, len(view.pages)): for at in range(1, len(view.pages)):
self._attach_at(view.parent, view, view.pages[at]) self._attach_at(view.parent, view, view.pages[at])
# Replace source file system path
view.pages[at].file.src_uri = view.file.src_uri
view.pages[at].file.abs_src_path = view.file.abs_src_path
# Prepare post for rendering (run later) - allow other plugins to alter # Prepare post for rendering (run later) - allow other plugins to alter
# the contents or metadata of a post before it is rendered and make sure # the contents or metadata of a post before it is rendered and make sure
# that the post includes a separator, which is essential for rendering # that the post includes a separator, which is essential for rendering
@ -640,6 +636,9 @@ class BlogPlugin(BasePlugin[BlogConfig]):
file = self._path_to_file(path, config) file = self._path_to_file(path, config)
files.append(file) files.append(file)
# Copy file to temporary directory
copy_file(view.file.abs_src_path, file.abs_src_path)
# Create view and attach to previous page # Create view and attach to previous page
if not isinstance(file.page, View): if not isinstance(file.page, View):
yield View(None, file, config) yield View(None, file, config)