Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #49
Only add one search term for each category page, and choose the most
general descriptor if necessary
  • Loading branch information
Mouq committed Feb 7, 2015
1 parent 2774c81 commit 1bd122c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions htmlify.p6
Expand Up @@ -519,12 +519,13 @@ sub write-search-file () {
sub escape(Str $s) {
$s.trans([</ \\ ">] => [<\\/ \\\\ \\">]);
}
my $items = <language type routine syntax>.map({
$*DR.lookup($_, :by<kind>).unique(:as{.name}).sort({.name})
}).flat.map({
.subkinds.map: -> $subkind {
qq[\{ label: "{$subkind.wordcase}: {escape .name}", value: "{escape .name}", url: "{.url}" \}]
}
my $items = <language type routine syntax>.map(-> $kind {
$*DR.lookup($kind, :by<kind>).categorize({escape .name})\
.pairs.sort({.key}).map: -> (:key($name), :value(@docs)) {
qq[[\{ label: "{
( @docs > 1 ?? $kind !! @docs.[0].subkinds[0] ).wordcase
}: $name", value: "$name", url: "{@docs.[0].url}" \}]] #"
}
}).join(",\n");
spurt("html/js/search.js", $template.subst("ITEMS", $items));
}
Expand Down

0 comments on commit 1bd122c

Please sign in to comment.