add rudimentary up navigation

This commit is contained in:
Cadence Ember
2025-11-23 03:00:44 +13:00
parent 54eaf4186f
commit e04ff565ee
2 changed files with 16 additions and 2 deletions

View File

@@ -32,4 +32,7 @@
(uri-decode (regexp-replace* #rx"#" str "/")))
(define (url-segments->guess-title segments)
(regexp-replace* #rx"_" (cadr segments) " "))
(string-join
(for/list ([s (in-list (cdr segments))])
(regexp-replace* #rx"_" s " "))
"/"))

View File

@@ -235,7 +235,18 @@
(main (@ (class "page__main"))
,(extwiki-notice wikiname title req user-cookies)
(div (@ (class "custom-top"))
(h1 (@ (class "page-title")) ,title)
(h1 (@ (class "page-title"))
;; adds rudimentary "up" navigation, e.g. /minecraft/wiki/Bastion_Remnant/Structure/Blueprints/Bastion_treasure_corners_edge_middle_blueprint
,@(let ([segments (string-split title "/")])
(add-between
(for/list ([segment (in-list segments)]
[depth (in-naturals 1)])
(define anti-depth (- (length segments) depth))
(define up-href (string-join (make-list anti-depth "..") "/"))
(if (non-empty-string? up-href)
`(a (@ (href ,(format "~a/~a" up-href segment))) ,segment)
segment))
"/")))
(nav (@ (class "sitesearch"))
(form (@ (action ,(format "/~a/search" wikiname))
(class "bw-search-form")