forked from open-telemetry/opentelemetry.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind-include.html
35 lines (28 loc) · 901 Bytes
/
find-include.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{{/*
Args: .path .page
Looks for the page specified by .path, starting from .page, moving up the
.Parent relation if necessary. If .path isn't explicitly absolute or relative,
"_includes/" is prepended to it.
*/ -}}
{{ $path := .path -}}
{{ if not (or
(strings.HasPrefix $path "/" )
(strings.HasPrefix $path "."))
-}}
{{ $path = printf "_includes/%s" $path -}}
{{ end -}}
{{ $result := partial "func/_find-include.html" (dict "path" $path "page" .page) -}}
{{ return $result -}}
{{ define "partials/func/_find-include.html" -}}
{{ $result := "" -}}
{{ $page_to_include := .page.GetPage .path -}}
{{ with $page_to_include -}}
{{ $result = . }}
{{ else -}}
{{ $parent := .page.Parent -}}
{{ if $parent -}}
{{ $result = partial "func/_find-include.html" (dict "path" .path "page" $parent) -}}
{{end -}}
{{ end -}}
{{ return $result -}}
{{ end -}}