Skip to content

Commit f58e687

Browse files
silverwindlunnywxiaoguang
authored
Shorten page title in file view (#17987)
Move the more relevant sections of the page title earlier which make it possible to distinguish multiple tabs from each other when tab width is limited. Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 4da1d97 commit f58e687

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

routers/web/repo/view.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ func renderDirectory(ctx *context.Context, treeLink string) {
141141
return
142142
}
143143

144+
if ctx.Repo.TreePath != "" {
145+
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
146+
}
147+
144148
// 3 for the extensions in exts[] in order
145149
// the last one is for a readme that doesn't
146150
// strictly match an extension
@@ -374,7 +378,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
374378
}
375379
defer dataRc.Close()
376380

377-
ctx.Data["Title"] = ctx.Data["Title"].(string) + " - " + ctx.Tr("repo.file.title", ctx.Repo.TreePath, ctx.Repo.RefName)
381+
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
378382

379383
fileSize := blob.Size()
380384
ctx.Data["FileIsSymlink"] = entry.IsLink()

0 commit comments

Comments
 (0)