@@ -235,7 +235,7 @@ def on_page_markdown(self, markdown, *, page, config, files):
235
235
# We set the contents of the view to its title if pagination should
236
236
# not keep the content of the original view on paginaged views
237
237
if not self .config .pagination_keep_content :
238
- view = page . pages [ 0 ] if isinstance (page , View ) else page
238
+ view = self . _resolve_canonical (page )
239
239
if view in self ._resolve_views (self .blog ):
240
240
assert isinstance (page , View )
241
241
if page .pages .index (page ):
@@ -324,7 +324,7 @@ def on_page_context(self, context, *, page, config, nav):
324
324
325
325
# Skip if page is not a view managed by this instance - this plugin has
326
326
# support for multiple instances, which is why this check is necessary
327
- view = page . pages [ 0 ] if isinstance (page , View ) else page
327
+ view = self . _resolve_canonical (page )
328
328
if view not in self ._resolve_views (self .blog ):
329
329
return
330
330
@@ -514,6 +514,13 @@ def _resolve_views(self, view: View):
514
514
assert isinstance (next , View )
515
515
yield next
516
516
517
+ # Resolve canonical page of a page, which might be a view
518
+ def _resolve_canonical (self , page : Page ):
519
+ if isinstance (page , View ):
520
+ return page .pages [0 ]
521
+ else :
522
+ return page
523
+
517
524
# Resolve siblings of a navigation item
518
525
def _resolve_siblings (self , item : StructureItem , nav : Navigation ):
519
526
if isinstance (item .parent , Section ):
@@ -631,6 +638,13 @@ def _attach(self, parent: StructureItem, pages: list[Page]):
631
638
page .previous_page = tail
632
639
page .next_page = head
633
640
641
+ # If the page is a view, we know that we generated it and need to
642
+ # link its siblings back to the view
643
+ if isinstance (page , View ):
644
+ view = self ._resolve_canonical (page )
645
+ if tail : tail .next_page = view
646
+ if head : head .previous_page = view
647
+
634
648
# Attach a page to the given parent and link it to the previous and next
635
649
# page of the given host - this is exclusively used for paginated views
636
650
def _attach_at (self , parent : StructureItem , host : Page , page : Page ):
0 commit comments