@@ -7,123 +7,34 @@ param name="request.wheels.params.format" default="html";
77local .docsPath = " /wheels/docs/src/" ;
88local .summaryPath = local .docsPath & " SUMMARY.md" ;
99
10- // Function to parse navigation from SUMMARY.md
11- function parseSummary (summaryPath ) {
12- local .nav = [];
13-
14- if (fileExists (arguments .summaryPath )) {
15- local .summaryContent = fileRead (arguments .summaryPath );
16- local .lines = listToArray (local .summaryContent , chr (10 ));
17-
18- local .currentSection = " " ;
19- local .currentSubsection = " " ;
20- local .currentItems = [];
21- local .currentSubItems = [];
22-
23- for (local .line in local .lines ) {
24- local .trimmedLine = trim (local .line );
25-
26- // Skip empty lines
27- if (! len (local .trimmedLine )) continue ;
28-
29- // Main section headers: "# " or "## "
30- if (reFind (" ^## {1,2}\s" , local .trimmedLine )) {
31- // Save previous section
32- if (len (local .currentSection )) {
33- arrayAppend (local .nav , {
34- " title" : local .currentSection ,
35- " items" : local .currentItems
36- });
37- }
38-
39- // Reset everything for new section
40- local .currentSection = trim (reReplace (local .trimmedLine , " ^## +\s*" , " " ));
41- local .currentItems = [];
42- local .currentSubsection = " " ;
43- local .currentSubItems = [];
44- }
45-
46- // Subsection title (not a link)
47- else if (reFind (" ^\*\s+[^\[]+$" , local .trimmedLine )) {
48- // If previous subsection exists, push it
49- if (len (local .currentSubsection ) && arrayLen (local .currentSubItems )) {
50- arrayAppend (local .currentItems , {
51- " title" : local .currentSubsection ,
52- " items" : local .currentSubItems
53- });
54- }
55-
56- local .currentSubsection = trim (reReplace (local .trimmedLine , " ^\*\s+" , " " ));
57- local .currentSubItems = [];
58- }
59-
60- // Navigation items (Markdown links)
61- else if (reFind (" ^\*\s+\[" , local .trimmedLine )) {
62- local .linkMatch = reMatch (" \*\s+\[([^\]]+)\]\(([^\)]+)\)" , local .trimmedLine );
63-
64- if (arrayLen (local .linkMatch )) {
65- local .title = reReplace (local .linkMatch [1 ], " \*\s+\[([^\]]+)\]\(([^\)]+)\)" , " \1" );
66- local .link = reReplace (local .linkMatch [1 ], " \*\s+\[([^\]]+)\]\(([^\)]+)\)" , " \2" );
67-
68- local .link = reReplace (local .link , " \.md$" , " " );
69- local .link = reReplace (local .link , " ^/" , " " );
70-
71- local .linkItem = {
72- " title" : local .title ,
73- " link" : local .link
74- };
75-
76- if (len (local .currentSubsection )) {
77- arrayAppend (local .currentSubItems , local .linkItem );
78- } else {
79- arrayAppend (local .currentItems , local .linkItem );
80- }
81- }
82- }
83- }
84-
85- // Final section/subsection flush
86- if (len (local .currentSubsection ) && arrayLen (local .currentSubItems )) {
87- arrayAppend (local .currentItems , {
88- " title" : local .currentSubsection ,
89- " items" : local .currentSubItems
90- });
91- }
92-
93- if (len (local .currentSection )) {
94- arrayAppend (local .nav , {
95- " title" : local .currentSection ,
96- " items" : local .currentItems
97- });
98- }
99- }
100-
101- return local .nav ;
102- }
103-
10410// Get navigation structure
105- local .navigation = parseSummary (local .summaryPath );
11+ local .docsHelper = new wheels .public .docs .DocsHelper ();
12+ local .navigation = local .docsHelper .parseSummary (local .summaryPath );
10613
10714// Determine which guide to display
10815local .guidePath = " " ;
10916local .guideContent = " " ;
11017local .guideTitle = " Wheels Documentation" ;
11118
11219if (len (request .wheels .params .path )) {
113- local .guidePath = local .docsPath & request .wheels .params .path & " .md" ;
20+ if (right (request .wheels .params .path , 3 ) eq ' .md' ){
21+ local .guidePath = local .docsPath & request .wheels .params .path ;
22+ } else {
23+ local .guidePath = local .docsPath & request .wheels .params .path & " .md" ;
24+ }
11425
11526 // Check if file exists
116- if (fileExists (local .guidePath )) {
117- local .guideContent = fileRead (local .guidePath );
27+ if (fileExists (expandPath ( local .guidePath ) )) {
28+ local .guideContent = fileRead (expandPath ( local .guidePath ) );
11829 local .guideTitle = request .wheels .params .path ;
11930 } else {
12031 local .guideContent = " Guide not found: " & request .wheels .params .path ;
12132 }
12233} else {
12334 // Default content - show introduction
12435 local .readmePath = local .docsPath & " README.md" ;
125- if (fileExists (local .readmePath )) {
126- local .guideContent = fileRead (local .readmePath );
36+ if (fileExists (expandPath ( local .readmePath ) )) {
37+ local .guideContent = fileRead (expandPath ( local .readmePath ) );
12738 local .guideTitle = " Introduction" ;
12839 } else {
12940 local .guideContent = " ## Wheels Documentation\n\nSelect a guide from the navigation menu." ;
0 commit comments