Skip to content

Commit 1bd122c

Browse files
committed
Fix #49
Only add one search term for each category page, and choose the most general descriptor if necessary
1 parent 2774c81 commit 1bd122c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

htmlify.p6

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,12 +519,13 @@ sub write-search-file () {
519519
sub escape(Str $s) {
520520
$s.trans([</ \\ ">] => [<\\/ \\\\ \\">]);
521521
}
522-
my $items = <language type routine syntax>.map({
523-
$*DR.lookup($_, :by<kind>).unique(:as{.name}).sort({.name})
524-
}).flat.map({
525-
.subkinds.map: -> $subkind {
526-
qq[\{ label: "{$subkind.wordcase}: {escape .name}", value: "{escape .name}", url: "{.url}" \}]
527-
}
522+
my $items = <language type routine syntax>.map(-> $kind {
523+
$*DR.lookup($kind, :by<kind>).categorize({escape .name})\
524+
.pairs.sort({.key}).map: -> (:key($name), :value(@docs)) {
525+
qq[[\{ label: "{
526+
( @docs > 1 ?? $kind !! @docs.[0].subkinds[0] ).wordcase
527+
}: $name", value: "$name", url: "{@docs.[0].url}" \}]] #"
528+
}
528529
}).join(",\n");
529530
spurt("html/js/search.js", $template.subst("ITEMS", $items));
530531
}

0 commit comments

Comments
 (0)