aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-04-18 03:05:19 +0800
committerGitHub <noreply@github.com>2023-04-17 15:05:19 -0400
commit1ab16e48cccc086e7f97fb3ae8a293fe47a3a452 (patch)
tree24f19185b5606ea605f5d74d6369dbfd4dc2d189 /templates/repo
parentf045e58cc7ba076a0ac4b0b5bf0702fa155eaa59 (diff)
downloadgitea-1ab16e48cccc086e7f97fb3ae8a293fe47a3a452.tar.gz
gitea-1ab16e48cccc086e7f97fb3ae8a293fe47a3a452.zip
Improve Wiki TOC (#24137)
The old code has a lot of technical debts, eg: `repo/wiki/view.tmpl` / `Iterate` This PR improves the Wiki TOC display and improves the code. --------- Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'templates/repo')
-rw-r--r--templates/repo/wiki/view.tmpl24
1 files changed, 6 insertions, 18 deletions
diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl
index a1d1c04751..318006d96e 100644
--- a/templates/repo/wiki/view.tmpl
+++ b/templates/repo/wiki/view.tmpl
@@ -65,28 +65,16 @@
<p>{{.FormatWarning}}</p>
</div>
{{end}}
- <div class="ui gt-mt-0 {{if or .sidebarPresent .toc}}grid equal width{{end}}">
- <div class="ui {{if or .sidebarPresent .toc}}eleven wide column{{else}}gt-ml-0{{end}} segment markup wiki-content-main">
+ <div class="ui gt-mt-0 {{if or .sidebarPresent .sidebarTocContent}}grid equal width{{end}}">
+ <div class="ui {{if or .sidebarPresent .sidebarTocContent}}eleven wide column{{else}}gt-ml-0{{end}} segment markup wiki-content-main">
{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
{{.content | Safe}}
</div>
- {{if or .sidebarPresent .toc}}
- <div class="column" style="padding-top: 0;">
- {{if .toc}}
+ {{if or .sidebarPresent .sidebarTocContent}}
+ <div class="column gt-pt-0">
+ {{if .sidebarTocContent}}
<div class="ui segment wiki-content-toc">
- <details open>
- <summary>
- <div class="ui header">{{.locale.Tr "toc"}}</div>
- </summary>
- {{$level := 0}}
- {{range .toc}}
- {{if lt $level .Level}}{{range Iterate (Eval .Level "-" $level)}}<ul>{{end}}{{end}}
- {{if gt $level .Level}}{{range Iterate (Eval $level "-" .Level)}}</ul>{{end}}{{end}}
- {{$level = .Level}}
- <li><a href="#{{.ID}}">{{.Text}}</a></li>
- {{end}}
- {{range Iterate $level}}</ul>{{end}}
- </details>
+ {{.sidebarTocContent | Safe}}
</div>
{{end}}
{{if .sidebarPresent}}