Skip to content

Commit 2160478

Browse files
committed
Create the menu items
1 parent 5a2f285 commit 2160478

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

htmlify.pl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@
88

99
my $head = slurp 'template/head.html';
1010
my $footer = footer-html;
11-
my $header = slurp 'template/header.html';
11+
sub header-html(%categories) {
12+
my $header = slurp 'template/header.html';
13+
my $menu-items = [~]
14+
q[<div class="menu-items dark-green">],
15+
%categories.keys.map( -> $category {qq[
16+
<a class="menu-item selected darker-green"
17+
href="/$category.html">
18+
{ $category.wordcase }
19+
</a>
20+
]}),
21+
q[</div>];
22+
my $menu-pos = ($header ~~ /MENU/).from;
23+
$header.subst('MENU', :p($menu-pos), $menu-items);
24+
}
1225

1326
my %categories =
1427
"best-of-rosettacode" => "Best of Rosettacode",
@@ -72,7 +85,7 @@ ($pod)
7285
pod2html $pod,
7386
:url(&url),
7487
:$head,
75-
:header($header),
88+
:header(header-html %categories),
7689
:$footer,
7790
:default-title("Perl 6 Examples");
7891
}

0 commit comments

Comments
 (0)