@@ -45,45 +45,46 @@ my @menu =
45
45
# ('formalities','' ) => ();
46
46
;
47
47
48
- my $ head = slurp ' template/head.html' ;
49
- sub header-html ($ current-selection = ' nothing selected' ) is cached {
48
+ my $ head = slurp ' template/head.html' ;
49
+
50
+ sub header-html ($ selection ) is cached {
50
51
state $ header = slurp ' template/header.html' ;
52
+ my $ with-active = $ header . subst (
53
+ /\<( li id="nav-$selection" )\> /,
54
+ { " <$/[0] class=" active" >" });
55
+
56
+ state $ sub-menu-pos = ($ header ~~ /SUBMENU /). from ;
57
+ if $ sub-menu-pos >= 0 {
58
+ my $ sub-menu-items = ' ' ;
59
+ state % sub-menus = @ menu >>. key >> [0 ] Z => @ menu >>. value ;
60
+ if % sub-menus {$ current-selection } -> $ _ {
61
+ $ sub-menu-items = [~ ]
62
+ q [ <div class="menu-items darker-green"> ] ,
63
+ qq [ <a class="menu-item" href="/$ current-selection .html">All</a> ] ,
64
+ . map ({qq [
65
+ <a class="menu-item" href="/$ current-selection\ -$ _ .html">
66
+ { . wordcase}
67
+ </a>
68
+ ] }),
69
+ q [ </div> ] ;
70
+ }
51
71
52
- my $ menu-items = [~ ]
53
- q [ <div class="menu-items dark-green"> ] ,
54
- @ menu >>. key . map (-> ($ dir , $ name ) {qq [
55
- <a class="menu-item { $ dir eq $ current-selection ?? " selected darker-green" !! " " } "
56
- href="/$ dir .html">
57
- { $ name || $ dir . wordcase }
58
- </a>
59
- ] }), # "
60
- q [ </div> ] ;
61
-
62
- my $ sub-menu-items = ' ' ;
63
- state % sub-menus = @ menu >>. key >> [0 ] Z => @ menu >>. value ;
64
- if % sub-menus {$ current-selection } -> $ _ {
65
- $ sub-menu-items = [~ ]
66
- q [ <div class="menu-items darker-green"> ] ,
67
- qq [ <a class="menu-item" href="/$ current-selection .html">All</a> ] ,
68
- . map ({qq [
69
- <a class="menu-item" href="/$ current-selection\ -$ _ .html">
70
- { . wordcase}
71
- </a>
72
- ] }),
73
- q [ </div> ]
74
- }
75
-
76
- state $ menu-pos = ($ header ~~ /MENU /). from ;
77
- $ header . subst (' MENU' , : p($ menu-pos ), $ menu-items ~ $ sub-menu-items );
72
+ $ header . subst (' SUBMENU' , : p($ sub-menu ), $ sub-menu-items );
73
+ }
78
74
}
79
75
80
76
sub p2h ($ pod , $ selection = ' nothing selected' , : $ pod-path = ' unknown' ) {
81
- pod2html $ pod ,
77
+ my $ html = pod2html $ pod ,
82
78
: url(& url-munge ),
83
79
: $ head ,
84
- : header(header-html $ selection ),
80
+ : header(header-html( $ selection ) ),
85
81
: footer(footer-html($ pod-path )),
86
- : default-title(" Perl 6 Documentation" ),
82
+ : default-title(" Perl 6 Documentation" );
83
+
84
+ # Pod::To::HTML should really not be injecting styles/classes/etc without
85
+ # any way to override them but it does :(
86
+ $ html . subst (rx {class="pod" }, q { class="bg" } );
87
+ return $ html ;
87
88
}
88
89
89
90
sub recursive-dir ($ dir ) {
@@ -643,6 +644,7 @@ sub write-index-files () {
643
644
say ' Writing html/index.html ...' ;
644
645
spurt ' html/index.html' ,
645
646
p2h(EVAL (slurp (' doc/HomePage.pod' ) ~ " \n \$=pod" ),
647
+ selected => ' home' ,
646
648
pod-path => ' HomePage.pod' );
647
649
648
650
say ' Writing html/language.html ...' ;
0 commit comments