Three new documentation pages under Geography > Semantics: - Capabilities: abstract evaluation contexts, capability primitives, standard capabilities, why not phases - Modules: the (use) form, what it enables, semantics - Eval Rules: machine-readable rule set, sx_explain tool, rule structure Navigation: semantics-nav-items with 3 entries, linked from geography nav tree after CEK Machine. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
17 lines
4.4 KiB
Plaintext
17 lines
4.4 KiB
Plaintext
;; Navigation tree structure and utility functions
|
|
|
|
(define find-current (fn (items slug) (when slug (some (fn (item) (when (ends-with? (get item "href") (str "." slug "))")) (get item "label"))) items))))
|
|
|
|
(defcomp ~nav-data/section-nav (&key items current) (<> (map (fn (item) (~shared:layout/nav-link :href (get item "href") :label (get item "label") :is-selected (when (= (get item "label") current) "true") :select-colours "aria-selected:bg-violet-200 aria-selected:text-violet-900")) items)))
|
|
|
|
(define sx-nav-tree {:href "/sx/" :children (list {:href "/sx/(geography)" :children (list {:href "/sx/(geography.(reactive))" :children reactive-islands-nav-items :label "Reactive Islands"} {:href "/sx/(geography.(hypermedia))" :children (list {:href "/sx/(geography.(hypermedia.(reference)))" :children reference-nav-items :label "Reference"} {:href "/sx/(geography.(hypermedia.(example)))" :children examples-nav-items :label "Examples"}) :label "Hypermedia Lakes"} {:href "/sx/(geography.(scopes))" :summary "The unified primitive beneath provide, collect!, spreads, and islands. Named scope with downward value, upward accumulation, and a dedup flag." :label "Scopes"} {:href "/sx/(geography.(provide))" :summary "Sugar for scope-with-value. Render-time dynamic scope — the substrate beneath spreads, CSSX, and script collection." :label "Provide / Emit!"} {:href "/sx/(geography.(spreads))" :summary "Child-to-parent communication across render boundaries — spread, collect!, reactive-spread, built on scopes." :label "Spreads"} {:href "/sx/(geography.(marshes))" :children marshes-examples-nav-items :summary "Where reactivity and hypermedia interpenetrate — server writes to signals, reactive transforms reshape server content, client state modifies how hypermedia is interpreted." :label "Marshes"} {:href "/sx/(geography.(isomorphism))" :children isomorphism-nav-items :label "Isomorphism"} {:href "/sx/(geography.(cek))" :children cek-nav-items :label "CEK Machine"} {:href "/sx/(geography.(capabilities))" :children semantics-nav-items :label "Semantics"}) :label "Geography"} {:href "/sx/(language)" :children (list {:href "/sx/(language.(doc))" :children docs-nav-items :label "Docs"} {:href "/sx/(language.(spec))" :children specs-nav-items :label "Specs"} {:href "/sx/(language.(spec.(explore.evaluator)))" :label "Spec Explorer"} {:href "/sx/(language.(bootstrapper))" :children bootstrappers-nav-items :label "Bootstrappers"} {:href "/sx/(language.(test))" :children testing-nav-items :label "Testing"}) :label "Language"} {:href "/sx/(applications)" :children (list {:href "/sx/(applications.(sx-urls))" :label "SX URLs"} {:href "/sx/(applications.(cssx))" :children cssx-nav-items :label "CSSX"} {:href "/sx/(applications.(protocol))" :children protocols-nav-items :label "Protocols"} {:href "/sx/(applications.(sx-pub))" :label "sx-pub"} {:href "/sx/(applications.(reactive-runtime))" :children reactive-runtime-nav-items :label "Reactive Runtime"}) :label "Applications"} {:href "/sx/(tools)" :children tools-nav-items :label "Tools"} {:href "/sx/(etc)" :children (list {:href "/sx/(etc.(essay))" :children essays-nav-items :label "Essays"} {:href "/sx/(etc.(philosophy))" :children philosophy-nav-items :label "Philosophy"} {:href "/sx/(etc.(plan))" :children plans-nav-items :label "Plans"}) :label "Etc"}) :label "sx"})
|
|
|
|
(define has-descendant-href? (fn (node path) (let ((children (get node "children"))) (when children (some (fn (child) (or (= (get child "href") path) (has-descendant-href? child path))) children)))))
|
|
|
|
(define find-nav-match (fn (items path) (or (some (fn (item) (when (= (get item "href") path) item)) items) (some (fn (item) (when (has-descendant-href? item path) item)) items))))
|
|
|
|
(define resolve-nav-path (fn (tree path) (let ((trail (list))) (define walk (fn (node) (let ((children (get node "children"))) (when children (let ((match (find-nav-match children path))) (when match (append! trail {:siblings children :node match}) (when (not (= (get match "href") path)) (walk match)))))))) (walk tree) (let ((depth (len trail))) (if (= depth 0) {:children (get tree "children") :depth 0 :trail trail} (let ((deepest (nth trail (- depth 1)))) {:children (get (get deepest "node") "children") :depth depth :trail trail}))))))
|
|
|
|
(define find-nav-index (fn (items node) (let ((target-href (get node "href")) (count (len items))) (define find-loop (fn (i) (if (>= i count) 0 (if (= (get (nth items i) "href") target-href) i (find-loop (+ i 1)))))) (find-loop 0))))
|
|
|