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

github.com/yanlinlin82/simple-style.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinlin Yan <yanlinlin82@gmail.com>2022-04-12 17:55:51 +0300
committerLinlin Yan <yanlinlin82@gmail.com>2022-04-12 17:55:51 +0300
commitbfbe9ae29ac06d9c48c719658978a533afc92bc3 (patch)
tree248c9416ab6b47b66a7cd30ecd4caf4e269dc630
parent641a854a0a705a5ddbb3badeb2bc23cc079f9de6 (diff)
Separate partial templates.
-rw-r--r--layouts/_default/baseof.html53
-rw-r--r--layouts/partials/footer.html10
-rw-r--r--layouts/partials/header.html19
-rw-r--r--layouts/partials/search-form.html19
-rw-r--r--layouts/partials/search.html36
5 files changed, 67 insertions, 70 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 1df2849..3a6ac89 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -4,62 +4,17 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="{{ .Site.BaseURL }}">
-{{ partial "html-meta.html" . -}}
+ {{ partial "html-meta.html" . -}}
<title>{{ if not .IsHome }}{{ .Title }} - {{ end }}{{ .Site.Title }}</title>
+ {{ with .Site.Params.favicon }}<link rel="shortcut icon" href="{{ . }}" type="image/x-icon">{{ end -}}
<link rel="stylesheet" type="text/css" href="{{ "/css/main.css" | relURL }}">
-{{ with .Site.Params.favicon -}}
- <link rel="shortcut icon" href="{{ . }}" type="image/x-icon">
-{{ end -}}
</head>
<body>
- <header>
- {{ with .Site.Menus.parent -}}
- <nav>
- {{ range . -}}
- <a href="{{ .URL }}">{{ .Name }}</a>
- {{ end -}}
- </nav>
- {{ end -}}
- <div>
- <h1><a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a></h1>
- {{- if .Site.Params.subtitle }}<h2><a href="{{ .Site.BaseURL }}">{{ .Site.Params.subtitle }}</a></h2>{{- end }}
- </div>
- <nav>
- {{- range .Site.Menus.main -}}
- <a href="{{ .URL }}">{{ .Name }}</a>
- {{- end -}}
- {{ if isset site.Params "search" -}}
- {{ if eq site.Params.Search "baidu" -}}
- {{ partial "search.html" (dict "url" "https://www.baidu.com/s" "key" "wd") -}}
- {{ else if eq site.Params.Search "google" -}}
- {{ partial "search.html" (dict "url" "https://www.google.com/search" "key" "q") -}}
- {{ else if eq site.Params.Search "bing" -}}
- {{ partial "search.html" (dict "url" "https://www.bing.com/search" "key" "q") -}}
- {{ else if eq site.Params.Search "duckduckgo" -}}
- {{ partial "search.html" (dict "url" "https://www.duckduckgo.com/" "key" "q") -}}
- {{ else -}}
- {{ errorf "Unknown 'Site.Params.Search' value '%s'! Only 'baidu' is supported now." site.Params.Search -}}
- {{ end -}}
- {{ end -}}
- </nav>
- </header>
+ {{ partial "header.html" . -}}
<main>
{{ block "main" . }}{{- end }}
</main>
- <footer>
- <div>
- <div>
- {{- if .Site.Copyright -}}
- {{ .Site.Copyright | markdownify }}
- {{- else -}}
- &copy; 2019 Linlin Yan. <a href="https://creativecommons.org/licenses/by/4.0/deed.zh">CC-BY-4.0</a>
- {{- end -}}
- {{- if .Site.Params.ShowThemeInfo -}}
- <p>Powered by <a href="https://gohugo.io/">Hugo</a> with <a href="https://github.com/yanlinlin82/simple-style">Simple-Style</a>
- {{- end -}}
- </div>
- </div>
- </footer>
+ {{ partial "footer.html" . -}}
{{ template "_internal/google_analytics.html" . -}}
{{ partial "github-corner.html" . -}}
{{ partial "external-links.html" . -}}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
new file mode 100644
index 0000000..4c6c13a
--- /dev/null
+++ b/layouts/partials/footer.html
@@ -0,0 +1,10 @@
+<footer>
+{{- if .Site.Copyright -}}
+ {{ .Site.Copyright | markdownify }}
+{{- else -}}
+ &copy; 2019 Linlin Yan. <a href="https://creativecommons.org/licenses/by/4.0/deed.zh">CC-BY-4.0</a>
+{{- end -}}
+{{- if .Site.Params.ShowThemeInfo -}}
+ Powered by <a href="https://gohugo.io/">Hugo</a> with <a href="https://github.com/yanlinlin82/simple-style">Simple-Style</a>
+{{- end -}}
+</footer>
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
new file mode 100644
index 0000000..36658e1
--- /dev/null
+++ b/layouts/partials/header.html
@@ -0,0 +1,19 @@
+<header>
+{{ with .Site.Menus.parent -}}
+ <nav>
+ {{ range . -}}
+ <a href="{{ .URL }}">{{ .Name }}</a>
+ {{ end -}}
+ </nav>
+{{ end -}}
+ <div>
+ <h1><a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a></h1>
+ {{- if .Site.Params.subtitle }}<h2><a href="{{ .Site.BaseURL }}">{{ .Site.Params.subtitle }}</a></h2>{{- end }}
+ </div>
+ <nav>
+ {{- range .Site.Menus.main -}}
+ <a href="{{ .URL }}">{{ .Name }}</a>
+ {{- end -}}
+ {{ partial "search.html" . }}
+ </nav>
+</header>
diff --git a/layouts/partials/search-form.html b/layouts/partials/search-form.html
new file mode 100644
index 0000000..2e6fc95
--- /dev/null
+++ b/layouts/partials/search-form.html
@@ -0,0 +1,19 @@
+<script>
+ function check_search() {
+ var s = document.getElementById('_display_keyword').value;
+ s = s.replace(/(^\s*)|(\s*$)/g, '');
+ if (s == '' || s == undefined || s == null) {
+ document.getElementById('_display_keyword').focus();
+ return false;
+ }
+ document.getElementById('{{ .key }}').value = s + " site:{{ site.BaseURL }}";
+ return true;
+ }
+</script>
+<form class="search" action="{{ .url }}" target="_blank" onsubmit="return check_search()">
+ <input id="_display_keyword" type="text" placeholder="Search.." name="keyword">
+ <input id="{{ .key }}" type="hidden" name="{{ .key }}">
+ <button type="submit"><svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="width:20px;height:20px;color:#333">
+ <path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
+ </svg></button>
+</form>
diff --git a/layouts/partials/search.html b/layouts/partials/search.html
index 9f56b98..eb2fdbb 100644
--- a/layouts/partials/search.html
+++ b/layouts/partials/search.html
@@ -1,21 +1,15 @@
-<div class="search">
- <script>
- function check_search() {
- var s = document.getElementById('_display_keyword').value;
- s = s.replace(/(^\s*)|(\s*$)/g, '');
- if (s == '' || s == undefined || s == null) {
- document.getElementById('_display_keyword').focus();
- return false;
- }
- document.getElementById('{{ .key }}').value = s + " site:{{ site.BaseURL }}";
- return true;
- }
- </script>
- <form class="search" action="{{ .url }}" target="_blank" onsubmit="return check_search()">
- <input id="_display_keyword" type="text" placeholder="Search.." name="keyword">
- <input id="{{ .key }}" type="hidden" name="{{ .key }}">
- <button type="submit"><svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" style="width:20px;height:20px;color:#333">
- <path d="M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
- </svg></button>
- </form>
-</div>
+{{ if isset site.Params "search" -}}
+<div class="search">
+ {{ if eq site.Params.Search "baidu" -}}
+ {{ partial "search-form.html" (dict "url" "https://www.baidu.com/s" "key" "wd") -}}
+ {{ else if eq site.Params.Search "google" -}}
+ {{ partial "search-form.html" (dict "url" "https://www.google.com/search" "key" "q") -}}
+ {{ else if eq site.Params.Search "bing" -}}
+ {{ partial "search-form.html" (dict "url" "https://www.bing.com/search" "key" "q") -}}
+ {{ else if eq site.Params.Search "duckduckgo" -}}
+ {{ partial "search-form.html" (dict "url" "https://www.duckduckgo.com/" "key" "q") -}}
+ {{ else -}}
+ {{ errorf "Unknown 'Site.Params.Search' value '%s'! Only 'baidu' is supported now." site.Params.Search -}}
+ {{ end -}}
+</div>
+{{ end -}}