77 use function com \keyman \help \kb \link_from_id ;
88
99 $ id = null ;
10- $ title = 'Knowledge Base index ' ;
10+ $ kb_title = 'Knowledge Base index ' ;
1111
1212 if (isset ($ _REQUEST ['id ' ])) {
1313 $ id = $ _REQUEST ['id ' ];
2424 } else {
2525 // We test the first line of the file for a title.
2626
27- $ text = explode (' \n ' , $ kb );
27+ $ text = explode ("\n" , $ kb );
2828 if (count ($ text ) > 0 ) {
2929 if (substr ($ text [0 ], 0 , 2 ) == '# ' ) {
30- $ title = trim (substr ($ text [0 ], 2 ));
30+ $ kb_title = trim (substr ($ text [0 ], 2 )) . sprintf ( " (KMKB%04.4d) " , intval ( $ id ));
3131 } else {
32- $ title = $ filename ;
32+ $ kb_title = $ filename ;
3333 }
3434 }
3535 }
3636 }
3737
3838 // Required
3939 head ([
40- 'title ' =>'Keyman Support | ' . $ title ,
40+ 'title ' =>'Keyman Support | ' . $ kb_title ,
4141 'css ' => ['template.css ' ,'prism.css ' , 'kb-search.css ' ],
4242 'showMenu ' => true ,
4343 'index ' => false
4444 ]);
45- echo "<h1>Knowledge Base index</h1> " ;
4645 if ($ id ) {
47- echo "<p> " ;
46+ $ ParsedownAndAlerts = new \Keyman \Site \Common \GFMAlerts ();
47+ echo $ ParsedownAndAlerts ->text ($ kb );
48+
49+ echo "<hr><p> " ;
50+ echo "<a href='/kb'>Knowledge Base index</a> | " ;
4851 $ pid = intval ($ id ,10 ) - 1 ;
49- if ($ pid > 0 ) echo "<a href=' " .link_from_id ($ pid )."'>< Previous article</a> " ;
52+ if ($ pid > 0 ) echo "<a href=' " .link_from_id ($ pid )."'>< Previous article</a> | " ;
5053 $ nid = intval ($ id ,10 ) + 1 ;
5154 if (file_exists (filename_from_id ($ nid ))) {
5255 echo "<a href=' " .link_from_id ($ nid )."'>Next article ></a> " ;
5356 }
54- echo "</p><hr> " ;
55- $ ParsedownAndAlerts = new \Keyman \Site \Common \GFMAlerts ();
56- echo $ ParsedownAndAlerts ->text ($ kb );
57+ echo "</p> " ;
5758 } else {
5859 $ query = trim ($ _GET ['q ' ] ?? '' );
60+ echo "<h1>Knowledge Base index</h1> " ;
5961 echo "<div class='search-bar'> " ;
6062 echo "<form> " ;
6163 echo "<span class='search-icon'>🔍</span> " ;
8183 echo "<li><a href=' " .link_from_id ($ id )."'>KMKB {$ matches [1 ]}: " . htmlspecialchars ($ title ) . "</a></li> " ;
8284 }
8385 }
84- }
8586 echo "</ul> " ;
87+ }
8688?>
0 commit comments