mirror of https://github.com/istio/istio.io.git
				
				
				
			Add support for skip_toc and skip_seealso front-matter values. (#1989)
This commit is contained in:
		
							parent
							
								
									75ab0f02e6
								
							
						
					
					
						commit
						5f2af0fd69
					
				| 
						 | 
				
			
			@ -100,7 +100,8 @@ The available front matter fields are:
 | 
			
		|||
|`publishdate`  | For blog posts, indicates the date of publication of the post
 | 
			
		||||
|`subtitle`     | For blog posts, supplies an optional subtitle to be displayed below the main title
 | 
			
		||||
|`attribution`  | For blog posts, supplies an optional author's name
 | 
			
		||||
|`toc`          | Set this to false to prevent the page from having a table of contents generated for it
 | 
			
		||||
|`skip_toc`     | Set this to true to prevent the page from having a table of contents generated for it
 | 
			
		||||
|`skip_seealso`     | Set this to true to prevent the page from having a "See also" section generated for it
 | 
			
		||||
|`force_inline_toc` | Set this to true to force the generated table of contents from being inserted inline in the text instead of in a sidebar
 | 
			
		||||
 | 
			
		||||
## Adding images
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,47 +11,53 @@
 | 
			
		|||
    {{ $page.Scratch.Set "seeAlso" false }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
{{ $headers := findRE "<h[23456].*?id=\".*?\".*?>.*?</h[23456]>" $page.Content }}
 | 
			
		||||
{{ $len := len $headers }}
 | 
			
		||||
 | 
			
		||||
{{ if or (gt $len 0) ($page.Scratch.Get "seeAlso") }}
 | 
			
		||||
    {{ $page.Scratch.Set "needTOC" true }}
 | 
			
		||||
    <nav id="TableOfContents">
 | 
			
		||||
        <ul>
 | 
			
		||||
            {{ $page.Scratch.Set "level" 50 }}
 | 
			
		||||
            {{ range $h := $headers }}
 | 
			
		||||
                {{ $level := index (index (findRE "<h[23456].*?" $h) 0) 2 | int }}
 | 
			
		||||
                {{ $id := replaceRE "<h[23456].*?id=\"(.*?)\".*?>.*?</h[23456]>" "$1" $h }}
 | 
			
		||||
                {{ $title := replaceRE "<h[23456].*?>(.*?)</h[23456]>" "$1" $h }}
 | 
			
		||||
                {{ $current := $page.Scratch.Get "level" | int }}
 | 
			
		||||
 | 
			
		||||
                {{ if gt $level $current }}
 | 
			
		||||
                    {{ $delta := sub $level $current }}
 | 
			
		||||
                    {{ range $index, $num := (seq $delta) }}
 | 
			
		||||
                        <ul>
 | 
			
		||||
                    {{ end }}
 | 
			
		||||
                {{ else if lt $level $current }}
 | 
			
		||||
                    {{ $delta := sub $current $level }}
 | 
			
		||||
                    {{ range $index, $num := (seq $delta) }}
 | 
			
		||||
                        </ul>
 | 
			
		||||
                    {{ end }}
 | 
			
		||||
                {{ end }}
 | 
			
		||||
 | 
			
		||||
                <li><a href="#{{ $id }}">{{ $title | safeHTML }}</a></li>
 | 
			
		||||
 | 
			
		||||
                {{ $page.Scratch.Set "level" $level }}
 | 
			
		||||
            {{ end }}
 | 
			
		||||
 | 
			
		||||
            {{ $delta := sub ($page.Scratch.Get "level") 50 }}
 | 
			
		||||
            {{ range $index, $num := (seq $delta) }}
 | 
			
		||||
                </ul>
 | 
			
		||||
            {{ end }}
 | 
			
		||||
 | 
			
		||||
            {{ if $page.Scratch.Get "seeAlso" }}
 | 
			
		||||
                {{ with $related }}
 | 
			
		||||
                    <li><a href="#see-also">See also</a></li>
 | 
			
		||||
                {{ end }}
 | 
			
		||||
            {{ end }}
 | 
			
		||||
        </ul>
 | 
			
		||||
    </nav>
 | 
			
		||||
{{ if $page.Params.skip_seealso }}
 | 
			
		||||
    {{ $page.Scratch.Set "seeAlso" false }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
 | 
			
		||||
{{ if not $page.Params.skip_toc }}
 | 
			
		||||
    {{ $headers := findRE "<h[23456].*?id=\".*?\".*?>.*?</h[23456]>" $page.Content }}
 | 
			
		||||
    {{ $len := len $headers }}
 | 
			
		||||
 | 
			
		||||
    {{ if or (gt $len 0) ($page.Scratch.Get "seeAlso") }}
 | 
			
		||||
        {{ $page.Scratch.Set "needTOC" true }}
 | 
			
		||||
        <nav id="TableOfContents">
 | 
			
		||||
            <ul>
 | 
			
		||||
                {{ $page.Scratch.Set "level" 50 }}
 | 
			
		||||
                {{ range $h := $headers }}
 | 
			
		||||
                    {{ $level := index (index (findRE "<h[23456].*?" $h) 0) 2 | int }}
 | 
			
		||||
                    {{ $id := replaceRE "<h[23456].*?id=\"(.*?)\".*?>.*?</h[23456]>" "$1" $h }}
 | 
			
		||||
                    {{ $title := replaceRE "<h[23456].*?>(.*?)</h[23456]>" "$1" $h }}
 | 
			
		||||
                    {{ $current := $page.Scratch.Get "level" | int }}
 | 
			
		||||
 | 
			
		||||
                    {{ if gt $level $current }}
 | 
			
		||||
                        {{ $delta := sub $level $current }}
 | 
			
		||||
                        {{ range $index, $num := (seq $delta) }}
 | 
			
		||||
                            <ul>
 | 
			
		||||
                        {{ end }}
 | 
			
		||||
                    {{ else if lt $level $current }}
 | 
			
		||||
                        {{ $delta := sub $current $level }}
 | 
			
		||||
                        {{ range $index, $num := (seq $delta) }}
 | 
			
		||||
                            </ul>
 | 
			
		||||
                        {{ end }}
 | 
			
		||||
                    {{ end }}
 | 
			
		||||
 | 
			
		||||
                    <li><a href="#{{ $id }}">{{ $title | safeHTML }}</a></li>
 | 
			
		||||
 | 
			
		||||
                    {{ $page.Scratch.Set "level" $level }}
 | 
			
		||||
                {{ end }}
 | 
			
		||||
 | 
			
		||||
                {{ $delta := sub ($page.Scratch.Get "level") 50 }}
 | 
			
		||||
                {{ range $index, $num := (seq $delta) }}
 | 
			
		||||
                    </ul>
 | 
			
		||||
                {{ end }}
 | 
			
		||||
 | 
			
		||||
                {{ if $page.Scratch.Get "seeAlso" }}
 | 
			
		||||
                    {{ with $related }}
 | 
			
		||||
                        <li><a href="#see-also">See also</a></li>
 | 
			
		||||
                    {{ end }}
 | 
			
		||||
                {{ end }}
 | 
			
		||||
            </ul>
 | 
			
		||||
        </nav>
 | 
			
		||||
    {{ end }}
 | 
			
		||||
{{ end }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue