summaryrefslogtreecommitdiff
path: root/layouts/_default/search.html
blob: 569cc9a63c7f41256b31b19f444455059a4a7a93 (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
{{ define "main" }}
<section class="search-page">
    <header class="search-page__header">
        <h1 class="search-page__heading">
            {{ .Title }}
        </h1>
        {{- with .Content }}
            <div class="search-page__description">
                {{ . }}
            </div>
        {{- else }}
        {{- $description := or .Description (lang.Translate "search.description" | default "Find posts by search term.") }}
            <p class="search-page__description">
                {{ $description }}
            </p>
        {{- end }}
    </header>

    <section class="search-page__container" aria-label="{{ lang.Translate "search.label" | default "Search all posts" }}">
        <form id="search-form" class="search-form" role="search" autocomplete="off">
            <label for="search-input" class="search-form__label">
                {{ lang.Translate "search.label" | default "Search all posts" }}
            </label>
            <div class="search-form__input-wrapper">
                <input
                    id="search-input"
                    class="search-form__input"
                    type="search"
                    data-index-url="{{ site.Home.RelPermalink }}index.json"
                    placeholder="{{ lang.Translate "search.placeholder" | default "Type to search..." }}"
                />
                <button
                    id="search-reset"
                    type="button"
                    class="search-form__reset"
                    aria-label="{{ lang.Translate "search.reset" | default "Clear search" }}"
                >
                    <span class="search-clear__icon" aria-hidden="true">&times;</span>
                </button>
            </div>
        </form>

    </section>

    <div id="search-results" class="search-page__results" aria-live="polite">
        <p class="search-results__count" hidden>
            <span id="search-results-number">0</span>
            {{ lang.Translate "search.matches" | default "matches" }}
        </p>

        <ul class="search-results__list" hidden></ul>

        {{- /* Hidden template, used for hydrating search results from index.json with JS */ -}}
        <template id="search-result-template">
            {{- $mockPost := dict 
                "Title" "TEMPLATE_TITLE"
                "RelPermalink" "TEMPLATE_URL"
                "Date" now
                "Summary" "TEMPLATE_SUMMARY"
                "Params" (dict "tags" (slice "TEMPLATE_TAG"))
            -}}
            <li class="search-results__list-item">
                {{- partial "list/post-card.html" $mockPost }}
            </li>
        </template>

    </div>
</section>
{{ end }}