Welcome to mirror list, hosted at ThFree Co, Russian Federation.

doc-layout.html « components « partials « layouts - github.com/wangchucheng/hugo-eureka.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3740e91fe2c5afc78cab26779a67b156c094449d (plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
{{ $hasToc := and (in .TableOfContents "<li>" ) (.Params.toc) }}
{{ $hasSidebar := or ($hasToc) (.Params.series) }}
<div class="lg:pt-12">
    <div class="flex flex-col md:flex-row bg-secondary-bg rounded">
        <div class="md:w-1/4 lg:w-1/5 border-e">
            <div class="sticky top-16 pt-6">
                {{ template "doc-sidebar" (dict "context" . "permalink" .Permalink) }}
            </div>

        </div>
        <div class="w-full md:w-3/4 lg:w-4/5 pb-8 pt-2 md:pt-8">
            <div class="flex">
                <div class="w-full lg:w-3/4 px-6">
                    {{ partial "components/post-article" . }}
                    
                    {{ with .GetTerms "tags" }}
                    {{ partial "components/post-tags" . }}
                    {{ end }}
                    {{ with .GetTerms "authors" }}
                    {{ partial "components/post-author" . }}
                    {{ end }}

                    {{ partial "components/post-edit" . }}

                    {{ partial "components/post-footer" . }}
                    {{ partial "comment" . }}
                </div>
                {{ if $hasSidebar}}
                <div class="hidden lg:block lg:w-1/4">
                    {{ if ne $hasToc false }}
                    {{ partial "components/post-toc" . }}
                    {{ end }}
                </div>
                {{ end }}
            </div>

        </div>


    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', () => {
        {{/* highlight.js */}}
        {{- if eq .Site.Params.highlight.handler "highlightjs" }}
        hljs.highlightAll();
        {{- end }}
        changeSidebarHeight();
        switchDocToc();
    })
</script>

{{ define "doc-sidebar" }}
{{/*  Deprecation warning(v1.0.0) starts */}}
{{ $parentLayout := partial "utils/hyphenate" (.context.Parent.Layout | default .context.Parent.Type) }}
{{/*  Deprecation warning(v1.0.0) ends */}}
{{ if eq $parentLayout "doc-list" }}
{{ template "list-pages" (dict "context" .context "permalink" .permalink) }}
{{ else if (findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?/$" .context.Permalink) }}
{{ template "list-pages" (dict "context" .context "permalink" .permalink) }}
{{ else }}
{{ template "doc-sidebar" (dict "context" .context.Parent "permalink" .permalink) }}
{{ end }}
{{ end }}

{{ define "list-pages" }}
<div id="sidebar-title" class="md:hidden mx-4 px-2 pt-4 pb-2 md:border-b text-tertiary-text md:text-primary-text">
    <span class="font-semibold">{{ i18n "toc" }}</span>
    <i class='fas {{ cond (eq .Site.Language.LanguageDirection "rtl") "fa-caret-left" "fa-caret-right" }} ms-1'></i>
</div>

<div id="sidebar-toc"
    class="hidden md:block overflow-y-auto mx-6 md:mx-0 pe-6 pt-2 md:max-h-doc-sidebar bg-primary-bg md:bg-transparent">
    <div class="flex flex-wrap ms-4 -me-2 p-2 bg-secondary-bg md:bg-primary-bg rounded">
        <a class="{{ if eq .context.Permalink .permalink }}text-eureka{{ end }} hover:text-eureka"
            href="{{ .context.Permalink }}">{{ .context.LinkTitle }}</a>
        
        {{ $versions := partial "get-versions" (dict "context" .context) }}
        {{ if $versions }}
        <div class="relative ms-2 cursor-pointer">
            <div id="doc-version" class="flex items-center bg-primary-bg md:bg-secondary-bg">
                {{ $version := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?" .context.Permalink }}
                <span class="ms-2 me-1">{{ cond (gt (len $version) 0) (index $version 0) "latest" }}</span>
                <i class='fas {{ cond (eq .Site.Language.LanguageDirection "rtl") "fa-caret-left" "fa-caret-right" }} w-4 h-4 me-1'></i>
            </div>
            <div id="version-options" class="hidden absolute start-0 bg-secondary-bg rounded z-40">
                {{ range $index, $value := $versions }}
                {{ if eq $index 0 }}
                <div class="ms-2 me-8 my-1">
                    <a class="" href="{{ $.context.Parent.Permalink }}">latest</a>
                </div>
                {{ end }}
                {{ $version := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?" . }}
                <div class="ms-2 me-8 my-1">
                    <a class="" href="{{ . }}">{{ index $version 0 }}</a>
                </div>
                {{ end }}
            </div>
        </div>
        <div class="fixed hidden inset-0 opacity-0 h-full w-full cursor-default z-0" id="switch-canvas">
        </div>
        <script>
            document.addEventListener('DOMContentLoaded', () => {
                switchDocVersion();
            })
        </script>
        {{ end }}


    </div>
    {{ template "list-items" (dict "context" .context "permalink" .permalink) }}
</div>
{{ end }}

{{ define "list-items"}}
<ul class="ps-6">
    {{ range .context.Pages }}
    {{ $version := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?/$" .Permalink }}
    {{ if eq (len $version) 0 }}
    <li class="py-2">
        <div class="{{ if .IsSection }} pb-2 {{ end }}">
            <a class="{{ if eq .Permalink $.permalink }} text-eureka {{ end }} hover:text-eureka"
                href="{{ .Permalink }}">{{ .LinkTitle }}</a>
        </div>
        {{ if .IsSection }}
        {{ template "list-items" (dict "context" . "permalink" $.permalink) }}
        {{ end }}
    </li>
    {{ end }}
    {{ end }}
</ul>
{{ end }}

{{ define "partials/get-versions" }}
{{/*  Deprecation warning(v1.0.0) starts */}}
{{ $parentLayout := partial "utils/hyphenate" (.context.Parent.Layout | default .context.Parent.Type) }}
{{/*  Deprecation warning(v1.0.0) ends */}}
{{ if eq $parentLayout "doc-list" }}
{{ range .context.Pages.Reverse }}
{{ $hasVersion := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?/$" .Permalink }}
{{ if $hasVersion}}
{{ $version := slice .Permalink }}
{{ $.context.Scratch.Add "versions" $version }}
{{ end }}
{{ end }}
{{ else }}
{{ range .context.Parent.Pages.Reverse }}
{{ $hasVersion := findRE "v?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?/$" .Permalink }}
{{ if $hasVersion }}
{{ $version := slice .Permalink }}
{{ $.context.Scratch.Add "versions" $version }}
{{ end }}
{{ end }}
{{ end }}
{{ $versions := .context.Scratch.Get "versions" }}
{{ .context.Scratch.Delete "versions" }}
{{ return $versions }}
{{ end }}