From 7c655a95058aa753355251eb78b83d31d44972ab Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 23 Aug 2022 14:07:20 +0200 Subject: Better navigation of related content --- scripts/page.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'scripts/page.lua') diff --git a/scripts/page.lua b/scripts/page.lua index 7378bfc..48eef6e 100644 --- a/scripts/page.lua +++ b/scripts/page.lua @@ -144,11 +144,20 @@ function generate_related(meta) meta.prev = meta.prev and d1_page_to_list_item(deref(meta.prev)) meta.next = meta.next and d1_page_to_list_item(deref(meta.next)) + if meta.prev then meta.prev.is_prev = true end + if meta.next then meta.next.is_next = true end + if not meta.prev and not meta.next then return nil end + local layout = meta.parent.list_layout + local layout_id = utils.stringify(layout.id) + if layout_id ~= "grid-2" and layout_id ~= "gallery-2" then + layout = common.prep_layout("grid-2") + end + return { url = meta.parent.url, - layout = meta.parent.list_layout, + layout = layout, prev = meta.prev, next = meta.next } -- cgit v1.2.3-70-g09d2