-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
136 lines (125 loc) · 4.01 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{{ define "header" }}
<figure class="logo">
<img src="logo.svg" />
<figcaption>A Query Language for JSON</figcaption>
</figure>
{{ end }}
{{ define "main" }}
<nav class="main">
<script>
function _init_version() {
fetch("/VERSIONS").then(r=>r.text()).then(body=>{
const elem = document.getElementById("version")
const versions = body.split("\n").filter(v=>v)
for (const v of versions.reverse()) {
const tag = v.split(' ')[0]
elem.add(new Option(tag, `/${tag}`))
}
elem.value = '/' + window.location.pathname.replace(/^\/*/, '').split('/', 1)[0]
})
}
if (document.readyState === 'complete') _init_version();
else window.addEventListener("load", _init_version)
</script>
<select id="version" oninput="window.location.href = `${event.currentTarget.value}`">
<option value="/main">Latest</option>
</select>
<ol>
<li><a href="#tutorial">Tutorial</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#libraries">Libraries</a></li>
<li><a href="#specification">Syntax</a></li>
<li><a href="#functions">Functions</a></li>
</ol>
</nav>
<article id="intro">
{{- .Content -}}
</article>
{{ with .Site.GetPage "wiki/Tutorial" -}}
<article id="tutorial">
<h1>Tutorial</h1>
{{/* https://github.com/gohugoio/hugo/issues/8383 */}}
{{ replaceRE "href=\"#([^\"]+)\"" "href=\"#wiki-$1\"" .TableOfContents | safeHTML }}
{{- .Content -}}
</article>
{{- end -}}
{{ with .Site.GetPage "wiki/Examples" -}}
<article id="examples">
<h1>Examples</h1>
{{/* https://github.com/gohugoio/hugo/issues/8383 */}}
{{ replaceRE "href=\"#([^\"]+)\"" "href=\"#wiki-$1\"" .TableOfContents | safeHTML }}
{{- .Content -}}
</article>
{{- end -}}
{{ with .Site.GetPage "wiki/Preview" -}}
<article id="preview">
<h1>Preview Features</h1>
{{- .Content -}}
</article>
{{- end -}}
{{ with .Site.GetPage "wiki/Libraries" -}}
<article id="libraries">
<h1>Libraries</h1>
{{- .Content -}}
</article>
{{- end -}}
{{ with readFile "spec/GRAMMAR.ABNF" -}}
{{ $spec := partial "spec.html" . }}
<article id="specification">
<h1>Syntax</h1>
{{ if fileExists "TAG_MESSAGE" -}}
{{ with readFile "TAG_MESSAGE" -}}
<section class="changelog">
{{ . | markdownify }}
</section>
{{ end -}}
{{ end -}}
<nav>
<ul><li>
{{ $lastlevel := 1 -}}
{{ $first := true -}}
{{ range (findRE "<h\\d id=\"[^\"]+\"[^>]*>[^<]+" $spec ) -}}
{{ $level := int (replaceRE "<h(\\d) id=\"([^\"]+)\"[^>]*>([^<]+)" "$1" .) -}}
{{ $id := replaceRE "<h. id=\"([^\"]+)\"[^>]*>([^<]+)" "spec-$1" . -}}
{{ if and (ne $id "spec-examples") (lt $level 3) -}}
{{ if gt $level $lastlevel -}}
<ul><li>
{{- else if lt $level $lastlevel -}}
{{ range after 1 (seq $lastlevel $level) -}}
</ul></li>
{{ end -}}
<li>
{{- else if not $first -}}
</li>
<li>
{{- end -}}
<a href="#{{ $id }}">{{ replaceRE "<h. id=\"([^\"]+)\"[^>]*>([^<]+)" "$2" . }}</a>
{{- $lastlevel = $level -}}
{{ $first = false -}}
{{ end -}}
{{ end -}}
</li></ul>
</nav>
{{- replace $spec "%%GRAMMAR%%" (transform.Highlight (partial "grammar.html" . ) "abnf") 1 | replaceRE "id=\"([^\"]+)\"" "id=\"spec-$1\"" | safeHTML -}}
</article>
{{- end -}}
{{ with .Site.Data.functions -}}
<article id="functions">
<h1>Built-in Functions</h1>
<nav>
<ul>
{{- range $file, $data := . }}
<li><a href="#func-{{ $data.name }}">{{ $data.name }}</a></li>
{{ end -}}
</ul>
</nav>
<dl>
{{- range $file, $data := . }}
{{ partial "function.html" $data }}
{{ end }}
</dl>
</article>
{{- end -}}
{{ end }}
{{ define "footer" }}
{{ end }}