File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "os"
1010 "path"
1111 "path/filepath"
12+ "slices"
1213 "sort"
1314 "strings"
1415 "unicode/utf8"
@@ -83,7 +84,21 @@ func (s *Server) showOrRender(w http.ResponseWriter, r *http.Request) {
8384 // If the path is not a directory, then it's a file, so we can render it,
8485 // let's check first if it's a markdown file
8586 if ext := strings .ToLower (filepath .Ext (currentPath )); ext == ".md" || ext == ".markdown" {
86- s .serveMarkdown (currentPath , w , r )
87+ // Check FullMarkdownRender first to avoid unnecessary filename extraction
88+ if s .FullMarkdownRender {
89+ s .serveMarkdown (currentPath , w , r )
90+ return
91+ }
92+
93+ // Not rendering all markdown, check if this is an index-like file
94+ filename := filepath .Base (currentPath )
95+ if slices .Contains (allowedIndexFiles , filename ) {
96+ s .serveMarkdown (currentPath , w , r )
97+ return
98+ }
99+
100+ // If not an index file and FullMarkdownRender is disabled, serve as plain text
101+ s .serveFile (0 , currentPath , w , r )
87102 return
88103 }
89104
You can’t perform that action at this time.
0 commit comments