add swiftype support

This commit is contained in:
ppoffice 2015-12-07 22:59:56 +08:00
parent f4e4b0edef
commit ed43419cc2
5 changed files with 65 additions and 16 deletions

View File

@ -122,7 +122,7 @@ banner: http://example.com/banner.jpg
### Custom Categories & Tags Pages ### Custom Categories & Tags Pages
To enable custom categories page and tags page, just copy the `categories` folder and `tags` folder under your theme's `_source` foler into your site's `source` folder. Then edit theme's _config.yml and add the following lines: To enable custom categories page and tags page, just copy the `categories` folder and `tags` folder under your theme's `_source` foler into your site's `source` folder. Then edit theme's _config.yml and add the following lines:
```r ```r
# Header # Header
menu: menu:
@ -140,6 +140,20 @@ English and Simplified Chinese are the default languages of the theme. You can a
language: zh-CN language: zh-CN
``` ```
## Swiftype
You can now enable **Swiftype** by editing blog's `_config.yml`.
``` yml
swiftype_install_key: XXX_XXXXXXXXXXXXXXXX
```
This `install key` can be found at your own engine's install page:
![](http://ppoffice.github.io/hexo-theme-icarus/gallery/swiftype_install.jpg "")
Finally, don't forget to save your swiftype configuration to complete the installation.
## Features ## Features
### Profile Sidebar ### Profile Sidebar

View File

@ -76,6 +76,8 @@ theme: icarus
# DuoShuo # DuoShuo
# duoshuo_shortname: hexo-theme-icarus # duoshuo_shortname: hexo-theme-icarus
# Swiftype
# swiftype_install_key: XXX_XXXXXXXXXXXXXXXX
# Deployment # Deployment
## Docs: http://hexo.io/docs/deployment.html ## Docs: http://hexo.io/docs/deployment.html

View File

@ -18,12 +18,23 @@
ds.type = 'text/javascript';ds.async = true; ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js'; ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8'; ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0] (document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds); || document.getElementsByTagName('body')[0]).appendChild(ds);
})(); })();
</script> </script>
<% } %> <% } %>
<% if (config.swiftype_install_key) { %>
<script type="text/javascript">
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');
_st('install','<%= config.swiftype_install_key %>','2.0.0');
</script>
<% } %>
<%- partial('cdn_after_footer') %> <%- partial('cdn_after_footer') %>
<% if (theme.fancybox){ %> <% if (theme.fancybox){ %>

View File

@ -15,7 +15,14 @@
</nav> </nav>
<% } %> <% } %>
<div id="search-form-wrap"> <div id="search-form-wrap">
<%- search_form({ button: ' ', text: __('index.search') }) %> <% if (config.swiftype_install_key) { %>
<form class="search-form">
<input type="text" class="st-default-search-input search-form-input" placeholder="<%= __('index.search') %>">
<button type="submit" class="search-form-submit"></button>
</form>
<% } else { %>
<%- search_form({ button: ' ', text: __('index.search') }) %>
<% } %>
</div> </div>
</div> </div>
</div> </div>
@ -26,7 +33,13 @@
<td><a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a></td> <td><a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a></td>
<% } %> <% } %>
<td> <td>
<%- search_form({ text: __('index.search') }) %> <% if (config.swiftype_install_key) { %>
<div class="search-form">
<input type="text" class="st-default-search-input search-form-input" placeholder="<%= __('index.search') %>">
</div>
<% } else { %>
<%- search_form({ text: __('index.search') }) %>
<% } %>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -19,7 +19,7 @@ $header-block-left
$header-block-right $header-block-right
float: right float: right
.header-inner .header-inner
height: 100% height: 100%
position: relative position: relative
@ -45,7 +45,7 @@ $header-block-right
top: 50% top: 50%
left: 0 left: 0
margin-top: logo-size * -0.5 margin-top: logo-size * -0.5
.header-sub .header-sub
border-top: 1px solid color-border border-top: 1px solid color-border
ul ul
@ -60,7 +60,7 @@ $header-block-right
.main-nav-link .main-nav-link
display: inline-block display: inline-block
line-height: header-sub-height line-height: header-sub-height
#header-sub #header-sub
@media mq-mobile @media mq-mobile
display: none display: none
@ -74,13 +74,13 @@ $header-block-right
display: none display: none
@media mq-mini @media mq-mini
display: none display: none
#main-nav-mobile #main-nav-mobile
@media mq-tablet @media mq-tablet
display: none display: none
@media mq-normal @media mq-normal
display: none display: none
$nav-link $nav-link
float: left float: left
@ -132,7 +132,7 @@ $nav-link
.search-form-input .search-form-input
width: 100% width: 100%
height: logo-size height: logo-size
padding: 0 30px 0 10px padding: 0 30px 0 15px
line-height: logo-size line-height: logo-size
border-radius: ((logo-size + 2)/2) border-radius: ((logo-size + 2)/2)
&::-webkit-search-results-decoration &::-webkit-search-results-decoration
@ -153,19 +153,28 @@ $nav-link
&:hover, &:focus &:hover, &:focus
color: #777 color: #777
.search-form-input .search-form-input,
.search-form-input.st-ui-search-input,
.search-form-input.st-default-search-input
-webkit-appearance: textarea
appearance: textarea
padding: 0
width: 200px width: 200px
outline: none
appearance: none
background: none
box-shadow: none box-shadow: none
color: color-default color: color-default
transition: 0.2s ease transition: 0.2s ease
box-sizing: border-box box-sizing: border-box
height: auto !important
line-height: line-height
outline: none !important
background: none !important
font: font-size font-sans font: font-size font-sans
border: 1px solid color-border border: 1px solid color-border !important
&:focus &:focus
border-color: color-link border-color: color-link !important
&::-webkit-search-results-decoration
&::-webkit-search-cancel-button
-webkit-appearance: none
#main-nav-mobile #main-nav-mobile
overflow-y: hidden overflow-y: hidden