diff --git a/modules/config.xqm b/modules/config.xqm index 1c1f9a2d..859f27fc 100644 --- a/modules/config.xqm +++ b/modules/config.xqm @@ -158,6 +158,9 @@ declare variable $config:facets := [ "dimension": "feature", "heading": "facets.feature", "source": "api/search/facets/feature", + "output": function($label) { + upper-case(substring($label,1,1)) || substring($label, 2) + }, "max": 5, "hierarchical": false() }, diff --git a/modules/facets.xql b/modules/facets.xql index 5f21d43c..e465f4df 100644 --- a/modules/facets.xql +++ b/modules/facets.xql @@ -23,12 +23,13 @@ import module namespace config="http://www.tei-c.org/tei-simple/config" at "conf declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare function facets:sort($facets as map(*)?) { +declare function facets:sort($config as map(*), $facets as map(*)?) { array { if (exists($facets)) then for $key in map:keys($facets) let $value := map:get($facets, $key) - order by $key ascending + let $sortKey := if (exists($config?output)) then $config?output($key) else $key + order by $sortKey ascending return map { $key: $value } else @@ -49,7 +50,7 @@ declare function facets:print-table($config as map(*), $nodes as element()+, $va if (map:size($facets) > 0) then