Skip to content

Please add option to disable auto TOC in the wiki. #21065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
13BTurbo opened this issue Sep 4, 2022 · 3 comments
Open

Please add option to disable auto TOC in the wiki. #21065

13BTurbo opened this issue Sep 4, 2022 · 3 comments
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@13BTurbo
Copy link

13BTurbo commented Sep 4, 2022

Feature Description

The new auto generated Wiki TOC is making some wiki content, particularly tables or graphics, too narrow.
Please add an option to disable the auto generated TOC.

I have tried adding the below, but that does not disable the auto generated TOC from rendering.

gitea: none
include_toc: false

Screenshots

No response

@13BTurbo 13BTurbo added type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first. labels Sep 4, 2022
@GlitterHorn
Copy link

It would be helpful if the main content wrapped around the TOC, too. This issue has some screenshots.

@GlitterHorn
Copy link

You can use a custom template file to change or hide the auto TOC.

The file is custom/templates/repo/wiki/view.tmpl - make sure you grab the right version for your server; this tripped me up.

The TOC is rendered on lines 73-91. To hide the TOC, remove this section. If you move the section to the first child of the main content div and add some inline CSS, you can make the TOC wrap like this:

<div class="ui {{if or .sidebarPresent .toc}}eleven wide column{{end}} segment markup wiki-content-main" style="width:100% !important;">
	{{if or .sidebarPresent .toc}}
	<div id="wraptoc" class="column" style="width:33%;float:right;background-color:var(--color-box-body);padding-top: 0;">
		{{if .toc}}
			<div class="ui segment wiki-content-toc" style="margin: 10px 0 0 10px;">
				<details open>
					<summary>
						<div class="ui header">{{.i18n.Tr "toc"}}</div>
					</summary>
					{{$level := 0}}
					{{range .toc}}
						{{if lt $level .Level}}{{range Iterate (Subtract .Level $level)}}<ul>{{end}}{{end}}
						{{if gt $level .Level}}{{range Iterate (Subtract $level .Level)}}</ul>{{end}}{{end}}
						{{$level = .Level}}
						<li><a href="#{{.ID}}">{{.Text}}</a></li>
					{{end}}
					{{range Iterate $level}}</ul>{{end}}
				</details>
			</div>
		{{end}}
		{{if .sidebarPresent}}
			<div class="ui segment wiki-content-sidebar">
				{{if and .CanWriteWiki (not .Repository.IsMirror)}}
					<a class="ui right floated muted" href="{{.RepoLink}}/wiki/_Sidebar?action=_edit" aria-label="{{.i18n.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a>
				{{end}}
				{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .sidebarEscapeStatus "root" $}}
				{{.sidebarContent | Safe}}
			</div>
		{{end}}
	</div>
	{{end}}
	{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
	{{.content | Safe}}
</div>

This produces the following:

image

@13BTurbo
Copy link
Author

Sure, that works fine for the entire site. But it would be more useful if it were possible on a per repository basis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

2 participants