generated from ElnuDev/go-project
Better template loading, word page
See https://stackoverflow.com/a/11468132
This commit is contained in:
parent
f558d7f0c1
commit
e70916c6c1
11 changed files with 236 additions and 87 deletions
|
@ -1,18 +1,25 @@
|
|||
{{- define "index" -}}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ with .Query }}{{ . }} search - {{ end }}jidict</title>
|
||||
<title>{{ block "title" . }}{{ template "sitetitle" . }}{{ end }}</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css">
|
||||
<style>
|
||||
li {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
#results .box h3 a {
|
||||
color: inherit;
|
||||
}
|
||||
#results .box h3 a:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||
</head>
|
||||
<body>
|
||||
<body hx-boost="true">
|
||||
<main>
|
||||
<a href="/">
|
||||
<img src="https://jichan.org/logo.svg" style="height: 4em; display: block; margin: 1em auto 1em auto">
|
||||
|
@ -20,13 +27,16 @@
|
|||
<form
|
||||
hx-get="/search"
|
||||
hx-replace-url="true"
|
||||
hx-target="#results">
|
||||
<input type="text" name="q"{{ with .Query }} value="{{ . }}"{{ end }} placeholder="辞書をサーチする" class="width:100%" autocomplete="false">
|
||||
hx-target="#results"
|
||||
hx-on::before-request="document.title = `${this.querySelector('input').value} search - jidict`">
|
||||
<input type="text" name="q" value="{{ block "value" . }}{{ end }}" placeholder="辞書をサーチする" class="width:100%" autocomplete="false" required>
|
||||
</form>
|
||||
<div id="results">
|
||||
{{ if .Count }}{{ template "search" . }}{{ end }}
|
||||
{{ block "results" . }}{{ if .Query }}{{ template "search" . }}{{ end }}{{ end }}
|
||||
</div>
|
||||
<br>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
{{- end -}}
|
||||
{{- template "index" . -}}
|
Reference in a new issue