Skip to content

Commit 92c48da

Browse files
authored
Merge pull request #95 from odinuge/readmeTxt
Fix rendering of non-markdown readme files
2 parents 6e4252d + 530f6c1 commit 92c48da

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

routers/repo/view.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func renderDirectory(ctx *context.Context, treeLink string) {
8888
ctx.Data["IsMarkdown"] = true
8989
buf = markdown.Render(buf, treeLink, ctx.Repo.Repository.ComposeMetas())
9090
default:
91+
// FIXME This is the only way to show non-markdown files
92+
// instead of a broken "View Raw" link
93+
ctx.Data["IsMarkdown"] = true
9194
buf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
9295
}
9396
ctx.Data["FileContent"] = string(buf)
@@ -156,8 +159,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
156159

157160
readmeExist := isMarkdown || markdown.IsReadmeFile(blob.Name())
158161
ctx.Data["ReadmeExist"] = readmeExist
159-
if readmeExist {
160-
// TODO: don't need to render if it's a README but not Markdown file.
162+
if readmeExist && isMarkdown {
161163
ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
162164
} else {
163165
// Building code view blocks with line number on server side.

0 commit comments

Comments
 (0)