aboutsummaryrefslogtreecommitdiffstats
path: root/layouts/partials/leading_image.html
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/leading_image.html')
-rw-r--r--layouts/partials/leading_image.html6
1 files changed, 3 insertions, 3 deletions
diff --git a/layouts/partials/leading_image.html b/layouts/partials/leading_image.html
index 0dda603..2f8e491 100644
--- a/layouts/partials/leading_image.html
+++ b/layouts/partials/leading_image.html
@@ -5,8 +5,8 @@
{{ $image = resources.Get (index .Params.images 0) }}
{{ end }}
{{ with $image }}
- <div class="tc">
- <div class="relative dib">
+ <div class="text-center">
+ <div class="relative inline-block">
<img
src="{{ if ne .MediaType.SubType "svg" }}
{{ $image := .Fit (default "768x400" $.Params.image_size) }}
@@ -20,7 +20,7 @@
{{ with $.Params.caption }}
<a
href="{{ .url }}"
- class="near-white block absolute bottom-0 right-0 p-2 bg-black-30 br2"
+ class="text-white block absolute bottom-0 right-0 p-2 bg-black bg-opacity-40 rounded"
>
{{ .text }}
</a>
neric.Emph */ .highlight .ges { color: #FFCB6B } /* Generic.EmphStrong */ .highlight .gr { color: #FF5370 } /* Generic.Error */ .highlight .gh { color: #C3E88D } /* Generic.Heading */ .highlight .gi { color: #C3E88D } /* Generic.Inserted */ .highlight .go { color: #546E7A } /* Generic.Output */ .highlight .gp { color: #FFCB6B } /* Generic.Prompt */ .highlight .gs { color: #FF5370 } /* Generic.Strong */ .highlight .gu { color: #89DDFF } /* Generic.Subheading */ .highlight .gt { color: #FF5370 } /* Generic.Traceback */ .highlight .kc { color: #89DDFF } /* Keyword.Constant */ .highlight .kd { color: #BB80B3 } /* Keyword.Declaration */ .highlight .kn { color: #89DDFF; font-style: italic } /* Keyword.Namespace */ .highlight .kp { color: #89DDFF } /* Keyword.Pseudo */ .highlight .kr { color: #BB80B3 } /* Keyword.Reserved */ .highlight .kt { color: #BB80B3 } /* Keyword.Type */ .highlight .ld { color: #C3E88D } /* Literal.Date */ .highlight .m { color: #F78C6C } /* Literal.Number */ .highlight .s { color: #C3E88D } /* Literal.String */ .highlight .na { color: #BB80B3 } /* Name.Attribute */ .highlight .nb { color: #82AAFF } /* Name.Builtin */ .highlight .nc { color: #FFCB6B } /* Name.Class */ .highlight .no { color: #EEFFFF } /* Name.Constant */ .highlight .nd { color: #82AAFF } /* Name.Decorator */ .highlight .ni { color: #89DDFF } /* Name.Entity */ .highlight .ne { color: #FFCB6B } /* Name.Exception */ .highlight .nf { color: #82AAFF } /* Name.Function */ .highlight .nl { color: #82AAFF } /* Name.Label */ .highlight .nn { color: #FFCB6B } /* Name.Namespace */ .highlight .nx { color: #EEFFFF } /* Name.Other */ .highlight .py { color: #FFCB6B } /* Name.Property */ .highlight .nt { color: #FF5370 } /* Name.Tag */ .highlight .nv { color: #89DDFF } /* Name.Variable */ .highlight .ow { color: #89DDFF; font-style: italic } /* Operator.Word */ .highlight .pm { color: #89DDFF } /* Punctuation.Marker */ .highlight .w { color: #EEFFFF } /* Text.Whitespace */ .highlight .mb { color: #F78C6C } /* Literal.Number.Bin */ .highlight .mf { color: #F78C6C } /* Literal.Number.Float */ .highlight .mh { color: #F78C6C } /* Literal.Number.Hex */ .highlight .mi { color: #F78C6C } /* Literal.Number.Integer */ .highlight .mo { color: #F78C6C } /* Literal.Number.Oct */ .highlight .sa { color: #BB80B3 } /* Literal.String.Affix */ .highlight .sb { color: #C3E88D } /* Literal.String.Backtick */ .highlight .sc { color: #C3E88D } /* Literal.String.Char */ .highlight .dl { color: #EEFFFF } /* Literal.String.Delimiter */ .highlight .sd { color: #546E7A; font-style: italic } /* Literal.String.Doc */ .highlight .s2 { color: #C3E88D } /* Literal.String.Double */ .highlight .se { color: #EEFFFF } /* Literal.String.Escape */ .highlight .sh { color: #C3E88D } /* Literal.String.Heredoc */ .highlight .si { color: #89DDFF } /* Literal.String.Interpol */ .highlight .sx { color: #C3E88D } /* Literal.String.Other */ .highlight .sr { color: #89DDFF } /* Literal.String.Regex */ .highlight .s1 { color: #C3E88D } /* Literal.String.Single */ .highlight .ss { color: #89DDFF } /* Literal.String.Symbol */ .highlight .bp { color: #89DDFF } /* Name.Builtin.Pseudo */ .highlight .fm { color: #82AAFF } /* Name.Function.Magic */ .highlight .vc { color: #89DDFF } /* Name.Variable.Class */ .highlight .vg { color: #89DDFF } /* Name.Variable.Global */ .highlight .vi { color: #89DDFF } /* Name.Variable.Instance */ .highlight .vm { color: #82AAFF } /* Name.Variable.Magic */ .highlight .il { color: #F78C6C } /* Literal.Number.Integer.Long */
// Options for fuse.js
let fuseOptions = {
    includeMatches: true,
    includeScore: true,
    ignoreLocation: true,
    minMatchCharLength: 3,
    keys: [
        { name: "title", weight: 0.8 },
        { name: "contents", weight: 0.4 },
        { name: "tags", weight: 0.5 },
        { name: "categories", weight: 0.5 },
    ],
}

function getUrlParameter(url, name) {
    const urlParams = new URLSearchParams(url)
    return urlParams.get(name)
}

function search(query, data){
    let fuse = new Fuse(data, fuseOptions)
    return fuse.search(query)
}

function unescapeText(input) {
    // Lifted from https://stackoverflow.com/posts/3700369/revisions
    var elem = document.createElement("textarea")
    elem.innerHTML = input
    return elem.value
}

function resultEntry(data, key) {
    // Pull template from hugo template definition
    let frag = document
        .getElementById("search-result-template")
        .content.cloneNode(true)

    // Replace values
    let { title, permalink, contents, date } = data
    frag.querySelector(".search_summary").setAttribute("id", "summary-" + key)
    frag.querySelector(".search_link").setAttribute("href", permalink)
    frag.querySelector(".search_title").textContent = title
    frag.querySelector(".search_snippet").textContent = unescapeText(contents)
    frag.querySelector(".search_time").textContent = date
    return frag
}


function executeSearch(searchQuery) {
    // Look for "index.json" in the same directory where this script is called.
    return fetch("index.json")
        .then((response) => response.json())
        .then((data) =>  search(searchQuery, data))
}

function renderResults(results) {
    let resultBox = document.getElementById("search-results")
    resultBox.innerHTML = ""

    // console.log("Results: ", results)
    if (results.length > 0) {
        results.forEach((value, key) => {
            resultBox.appendChild(resultEntry(value.item, key))
        })
    } else {
        resultBox.innerHTML = document.getElementById("no-match").innerHTML
    }
}

addEventListener("load", function () {
    let searchQuery = getUrlParameter(location.search, "q")
    if (searchQuery) {
        document.getElementById("search-query").value = searchQuery
        executeSearch(searchQuery).then(renderResults)
    }
}
)