File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,15 @@ func Type(filename string) string {
59
59
return ""
60
60
}
61
61
62
+ // ReadmeFileType reports whether name looks like a README file
63
+ // based on its name and find the parser via its ext name
64
+ func ReadmeFileType (name string ) (string , bool ) {
65
+ if IsReadmeFile (name ) {
66
+ return Type (name ), true
67
+ }
68
+ return "" , false
69
+ }
70
+
62
71
// IsReadmeFile reports whether name looks like a README file
63
72
// based on its name.
64
73
func IsReadmeFile (name string ) bool {
Original file line number Diff line number Diff line change @@ -56,13 +56,19 @@ func renderDirectory(ctx *context.Context, treeLink string) {
56
56
57
57
var readmeFile * git.Blob
58
58
for _ , entry := range entries {
59
- if entry .IsDir () || ! markup .IsReadmeFile (entry .Name ()) {
59
+ if entry .IsDir () {
60
+ continue
61
+ }
62
+
63
+ tp , ok := markup .ReadmeFileType (entry .Name ())
64
+ if ! ok {
60
65
continue
61
66
}
62
67
63
- // TODO: collect all possible README files and show with priority.
64
68
readmeFile = entry .Blob ()
65
- break
69
+ if tp != "" {
70
+ break
71
+ }
66
72
}
67
73
68
74
if readmeFile != nil {
You can’t perform that action at this time.
0 commit comments