@@ -76,8 +76,8 @@ func preblock(filename string) string {
7676 weight = prevWeight
7777 }
7878
79- file := strings . Split (filename , markdownExtension )
80- name := filepath . Base ( file [ 0 ] )
79+ baseName := filepath . Base (filename )
80+ name := strings . TrimSuffix ( baseName , markdownExtension )
8181 title := strings .ReplaceAll (name , "-" , " " )
8282
8383 return fmt .Sprintf (frontmdtemplate , title , weight )
@@ -114,8 +114,10 @@ func MarkdownCustom(cmd *cobra.Command, w io.Writer, linkHandler func(string) st
114114 name := cmd .CommandPath ()
115115
116116 buf .WriteString ("## " + name + "\n \n " )
117- buf .WriteString ("### Description\n \n " )
118- buf .WriteString ("##### " + cmd .Short + "\n \n " )
117+ if len (cmd .Short ) > 0 {
118+ buf .WriteString ("### Description\n \n " )
119+ buf .WriteString ("##### " + cmd .Short + "\n \n " )
120+ }
119121 if len (cmd .Long ) > 0 {
120122 buf .WriteString ("### Synopsis\n \n " )
121123 buf .WriteString (cmd .Long + "\n \n " )
@@ -247,7 +249,8 @@ func getWeight(filename string) int {
247249 var fm FrontMatter
248250 err = yaml .Unmarshal ([]byte (yamlContent ), & fm )
249251 if err != nil {
250- panic (err )
252+ log .Warningf ("Failed to parse YAML in file %s" , filename )
253+ return 0
251254 }
252255 return fm .Weight
253256}
0 commit comments