File size: 6,553 Bytes
bc8bf33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{{- define "head" }}
    {{- $instance := partial "partials/fediverse/instance.html" . }}
    {{- $username := partial "partials/fediverse/username.html" .}}
    {{ if and $instance $username }}
        <meta name="fediverse:creator" content="{{ print "@" $username "@" $instance }}">
    {{ end }}
    {{- /*

        MathML render engine    */}}
    {{- if or .Params.Math site.Params.Math }}
        {{ partialCached "head/js/katex.html" . }}
    {{- else if or .Params.MathJax site.Params.MathJax }}
        {{ partialCached "head/js/mathjax.html" . }}
    {{- end }}
    {{- /*

        Verbatim Style */}}
    {{- with findRE `class="chroma"` .Content 1 }}
        {{ partialCached "head/css/verbatim.html" $ }}
    {{- end }}
    {{- /*

        use Highlight.js */}}
    {{- if .Params.Hljs -}}
        {{ partialCached "head/css/verbatim.html" . }}
        {{ partialCached "head/js/hljs.html" . }}
    {{- end }}
    {{- /*

        QRCode */}}
    {{/*  {{ partialCached "head/js/qrcode.html" . }}  */}}
{{- end }}

{{- define "main" }}
    {{- $commentIsEnable :=  not site.Params.comments.disabled}}
    {{- $commentUrl := or .Params.toot .Params.comment }}
    {{- $instance := partial "partials/fediverse/instance.html" . }}
    {{- $username :=  partial "partials/fediverse/username.html" . }}
    {{- $post := partial "partials/fediverse/post.html" . }}
    {{- $commentIsToot := false }}
    {{- $avatar := false }}
    {{- $displayName := false }}
    {{- if and $commentIsEnable $instance $username $post }}
        {{- $api := print "https://" $instance "/api/v1/statuses/" $post }}
        {{- with resources.GetRemote $api }}
            {{- $data := . | transform.Unmarshal }}
            {{- $commentIsToot = $data.content }}
            {{- $commentUrl = $data.url }}
            {{- $avatar = $data.account.avatar }}
            {{- $displayName = $data.account.display_name }}
        {{- end }}
    {{- end }}

    <article id="main-article" class="pagewidth"
        role="document" aria-labelledby="title"
        {{- if ne (lower .Params.type) (or "post" "articles") }}
            data-pagefind-ignore="all"
        {{- else }}
            data-pagefind-body
        {{- end }}>
        <header class="textwidth" aria-labelledby="title">
            {{ partial "page/title.html" . }}
            <div id="doc-author" class="textsw author">
                {{- $author := cond .Params.author .Params.author site.Params.Author.name }}
                {{- $authors := .GetTerms "author" }}
                {{- $notMultiAuthor := eq (len $authors) 1 }}
                {{- if $authors }}
                    {{- if $notMultiAuthor }}
                        {{- range $authors }}
                            {{ $flair := .Params.flair }}
                            {{- if and $commentIsEnable $commentIsToot }}
                                <a id="avatar" href="{{ print "https://" $instance "/@" $username }}" aria-label="{{ $displayName }}">
                                    <img src="{{ $avatar }}" alt="{{ $displayName }}"/>
                                </a>
                            {{- else if $flair }}
                                {{- $displayPicture := partial "partials/page/cover.html" (dict "page" .) }}
                                <a id="avatar" href="{{ .Permalink }}" aria-label="{{ .LinkTitle }}">
                                    <img src="{{ $displayPicture }}" alt="{{ .LinkTitle }}"/>
                                </a>
                            {{- end }}
                            <a href="{{ .Permalink }}"
                                {{- if and $commentIsEnable $commentIsToot }}
                                    class="has-aria-label"
                                    aria-label="{{ print "@" $username "@" $instance}}"
                                {{- else if $flair }}
                                    class="has-aria-label"
                                    aria-label="{{ $flair }}"
                                {{- end }}>
                                {{- .LinkTitle -}}
                            </a>
                        {{- end }}
                    {{- else }}
                        {{ partial "terms.html" (dict "taxonomy" "author" "class" "delimiter" "page" .) }}
                    {{- end }}
                {{- else if $author -}}
                    <span>{{ $author }}</span>
                {{- end }}
            </div>
            {{ partial "page/timestamp.html" . }}
        </header>
        {{- with .Params.toc }}
            {{ partial "nav.html" (dict "navID" "TableOfContents" "page" $) }}
        {{- end }}
        {{ partial "page/audio.html" . }}
        <section aria-labelledby="Title" id="content" data-bionRead-safe {{- with .Params.secnum }} class="secnum"{{- end }}>
            {{- if or .Params.task site.Params.Post.enableCheckbox }}
                {{ replace .Content "disabled=" "" | safeHTML }}
            {{- else }}
                {{ .Content }}
            {{- end }}
        </section>
        <footer>
            {{ partial "post/tagged.html" . }}
        </footer>
    </article>
    <hr class="hide" style="margin: 1in 0;">
    <div id="contentinfo" class="pagewidth" role="contentinfo" data-pagefind-ignore="all">
        {{- if or .Params.related site.Params.posts.related }}
            {{ partial "post/related.html" . }}
        {{- end }}
        {{- if not site.Params.posts.disableHistory }}
            {{ partial "post/history.html" . }}
        {{- end }}
        {{- if or .Params.colophon site.Params.posts.colophon }}
            {{ partial "post/colophon.html" . }}
        {{- end }}
        {{ partial "post/contribute.html" . }}
        {{- if site.Params.posts.share }}
            {{ partial "nav.html" (dict "navID" "share" "page" .) }}
        {{- end }}
        {{- if $commentIsEnable }}
            {{- if $commentIsToot }}
                {{ partial "fediverse.html" (dict "instance" $instance "user" $username "post" $post "tootContent" $commentIsToot "commentUrl" $commentUrl) }}
            {{- end }}
        {{- end }}
    </div>
{{- end }}

{{- define "post" }}
    {{ "<!-- [post] single.html -->" | safeHTML }}
    {{- /* display color palette for pages with code blocks */}}
    {{- with findRE `class="chroma"` .Content 1 -}}
        <script>document.getElementById('setColorPalette').setAttribute('style', 'display:flex;');</script>
    {{- end }}
    {{- /*

        bionRead Snapshot */}}
    <div id="bionReadSnapshot" hidden></div>
{{- end }}