diff options
author | Lutong Chen <ertuil98@foxmail.com> | 2020-05-26 16:14:44 +0300 |
---|---|---|
committer | Lutong Chen <ertuil98@foxmail.com> | 2020-05-26 16:14:44 +0300 |
commit | 5af5e8437f638d6ab365848fbf73f8327c6ef37b (patch) | |
tree | b2f0b48a12f803680a4da530b3137da9c9f96e5c | |
parent | e0fedeaa88e97b4bdb72ab8c04457e71c0af1243 (diff) |
google intra-site search engine
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | exampleSite/config.toml | 1 | ||||
-rw-r--r-- | layouts/index.html | 12 | ||||
-rw-r--r-- | layouts/partials/head.html | 3 |
4 files changed, 16 insertions, 1 deletions
@@ -54,6 +54,7 @@ There are some basic configuration options you may want to use: | Params.logo | Your Blog's Logo | None | | Params.favicon | The favicon file | /favicon.ico | | Params.index_posts_num | The number of posts displayed in Index | 5 | +| Params.google_search | Enable Google Intra-Site Search Engine | false | | Params.badge | The color for badge ('red', 'cyan', 'orange', 'green', 'blue', 'black' and 'gray' are available) | 'red' | | Params.quote | The color for quota ('red', 'cyan', 'orange', 'green', 'blue', 'black' and 'gray' are available) | 'green' | diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 8c98762..7e5be1c 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -12,6 +12,7 @@ footnoteReturnLinkContents = "^" badge = "orange" quote = "red" index_posts_num = 5 + google_search = true # logo = "//blog.ertuil.top/avater.png" bio = """ <p> This is BIO. You can write something here. </p> diff --git a/layouts/index.html b/layouts/index.html index 581dc7d..f7931ec 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -41,6 +41,18 @@ </div> <div class="layui-col-md4 layui-col-sm4 layui-col-xs12"> + + {{if $.Site.Params.google_search}} + <input id="search" type="text" name="search" placeholder="站内搜索" autocomplete="off" class="layui-input"> + <script type="text/javascript"> + $("#search").keyup(function(event){ + if(event.keyCode ==13){ + document.location = "https://www.google.com/search?q=" + $("#search").val(); + "+site%3A{{$.Site.BaseURL}}" + } + }); + </script> + {{end}} + {{ range $taxonomyname, $taxonomy := .Site.Taxonomies }} <h1><a href="{{ "/" | relLangURL}}{{ $taxonomyname | urlize }}">{{ $taxonomyname }}</a> </h1> {{ range $key, $value := $taxonomy }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 9949e5b..5a316e7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -38,7 +38,7 @@ <link rel="stylesheet" href="/layui/css/layui.css"> <link rel="stylesheet" href="/self/css/default.css"> - <script async src="/layui/layui.js"></script> + <script src="/layui/layui.js"></script> <link rel="stylesheet" async href="/self/css/markdown.min.css"> <link rel="stylesheet" async href="/self/css/gallery.css"> @@ -46,6 +46,7 @@ <!-- <link rel="stylesheet" async href="/font-awesome-4.7.0/css/font-awesome.min.css"> --> <!-- <script src="/self/js/lazysizes.min.js" async></script> --> + <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous"> <script async src="https://cdn.jsdelivr.net/npm/lazysizes@5.2.0/lazysizes.min.js" integrity="sha256-h2tMEmhemR2IN4wbbdNjj9LaDIjzwk2hralQwfJmBOE=" crossorigin="anonymous"></script> {{- partial "self-define-head.html" -}} |