Skip to content
Snippets Groups Projects
Commit a3961d9c authored by Tommy Chen's avatar Tommy Chen
Browse files

Try algolia search

parent a7e0d837
Branches
Tags
No related merge requests found
...@@ -24,6 +24,8 @@ deploy: ...@@ -24,6 +24,8 @@ deploy:
disqus_shortname: hexojs disqus_shortname: hexojs
google_analytics: UA-4910098-10 google_analytics: UA-4910098-10
fb_admins: 100000247608790 fb_admins: 100000247608790
swiftype_key: EwN4HMy_KMxTK_GMjV1z algolia:
api_key: c3d5d4c995b5e0c2ffb5623900279a66
index_name: hexo
twitter: hexojs twitter: hexojs
github: hexojs/hexo github: hexojs/hexo
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"hexo": { "hexo": {
"version": "3.1.1" "version": "3.2.0-beta.2"
}, },
"scripts": { "scripts": {
"build": "hexo generate && gulp", "build": "hexo generate && gulp",
...@@ -40,4 +40,4 @@ ...@@ -40,4 +40,4 @@
"optionalDependencies": { "optionalDependencies": {
"hexo-browsersync": "^0.2.0" "hexo-browsersync": "^0.2.0"
} }
} }
\ No newline at end of file
...@@ -74,9 +74,7 @@ hexo.extend.helper.register('header_menu', function(className){ ...@@ -74,9 +74,7 @@ hexo.extend.helper.register('header_menu', function(className){
_.each(menu, function(path, title){ _.each(menu, function(path, title){
if (!isEnglish && ~localizedPath.indexOf(title)) path = lang + path; if (!isEnglish && ~localizedPath.indexOf(title)) path = lang + path;
result += '<li class="' + className + '-item">';
result += '<a href="' + self.url_for(path) + '" class="' + className + '-link">' + self.__('menu.' + title) + '</a>'; result += '<a href="' + self.url_for(path) + '" class="' + className + '-link">' + self.__('menu.' + title) + '</a>';
result += '</li>';
}); });
return result; return result;
...@@ -154,4 +152,4 @@ hexo.extend.helper.register('disqus_lang', function(){ ...@@ -154,4 +152,4 @@ hexo.extend.helper.register('disqus_lang', function(){
var data = this.site.data.languages[lang]; var data = this.site.data.languages[lang];
return data.disqus_lang || lang; return data.disqus_lang || lang;
}); });
\ No newline at end of file
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
<div class="article"> <div class="article">
<div class="inner"> <div class="inner">
<header class="article-header"> <header class="article-header">
<h1 class="article-title" itemprop="name" data-swiftype-name="title" data-swiftype-type="string">{{ page.title }}</h1> <h1 class="article-title" itemprop="name">{{ page.title }}</h1>
<a href="{{ raw_link(page.source) }}" class="article-edit-link" title="{{ __('page.improve') }}"><i class="fa fa-pencil"></i></a> <a href="{{ raw_link(page.source) }}" class="article-edit-link" title="{{ __('page.improve') }}"><i class="fa fa-pencil"></i></a>
</header> </header>
<div class="article-content" itemprop="articleBody" data-swiftype-name="body" data-swiftype-type="text"> <div class="article-content" itemprop="articleBody">
{{ page_anchor(page.content) }} {{ page_anchor(page.content) }}
</div> </div>
<footer class="article-footer"> <footer class="article-footer">
...@@ -31,4 +31,4 @@ ...@@ -31,4 +31,4 @@
{{ partial('partial/sidebar') }} {{ partial('partial/sidebar') }}
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
{{ js('js/plugins') }} {{ js('js/plugins') }}
<!-- endbuild --> <!-- endbuild -->
{% endif %} {% endif %}
<!-- Swiftype --> <!-- Algolia -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){ docsearch({
(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t); apiKey: '{{ config.algolia.api_key }}',
e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e); indexName: '{{ config.algolia.index_name }}',
})(window,document,'script','https://s.swiftypecdn.com/install/v2/st.js','_st'); inputSelector: '#search-input'
});
_st('install','{{ config.swiftype_key }}','2.0.0'); </script>
</script>
\ No newline at end of file
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<!-- endbuild --> <!-- endbuild -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css">
<!-- RSS --> <!-- RSS -->
{{ feed_tag('atom.xml') }} {{ feed_tag('atom.xml') }}
<!-- Open Graph --> <!-- Open Graph -->
...@@ -40,8 +41,6 @@ ...@@ -40,8 +41,6 @@
fb_admins: config.fb_admins, fb_admins: config.fb_admins,
twitter_site: config.twitter twitter_site: config.twitter
}) }} }) }}
<!-- Swiftype -->
<meta name="st:title" content="{{ page.title || config.title }}">
<!-- Google Analytics --> <!-- Google Analytics -->
{{ partial('google_analytics') }} {{ partial('google_analytics') }}
</head> </head>
\ No newline at end of file
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
<a href="{{ url_for_lang('') }}" id="logo">Hexo</a> <a href="{{ url_for_lang('') }}" id="logo">Hexo</a>
</h1> </h1>
<nav id="main-nav"> <nav id="main-nav">
<ul> {{ header_menu('main-nav') }}
{{ header_menu('main-nav') }} <a href="https://github.com/{{ config.github }}" class="main-nav-link"><i class="fa fa-github-alt"></i></a>
<li class="main-nav-item">
<a href="https://github.com/{{ config.github }}" class="main-nav-link"><i class="fa fa-github-alt"></i></a>
</li>
</ul>
</nav> </nav>
<div id="search-input-wrap">
<input type="search" id="search-input" placeholder="Search...">
</div>
<div id="lang-select-wrap"> <div id="lang-select-wrap">
<label id="lang-select-label"><i class="fa fa-globe"></i><span>{{ lang_name(page.lang) }}</span></label> <label id="lang-select-label"><i class="fa fa-globe"></i><span>{{ lang_name(page.lang) }}</span></label>
<select id="lang-select" data-canonical="{{ canonical_path_for_nav() }}"> <select id="lang-select" data-canonical="{{ canonical_path_for_nav() }}">
...@@ -19,14 +18,10 @@ ...@@ -19,14 +18,10 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div id="search-btn-wrap" class="main-nav-item">
<a id="search-btn" class="main-nav-link st-search-show-outputs"><i class="fa fa-search"></i></a>
</div>
<a id="mobile-nav-toggle"> <a id="mobile-nav-toggle">
<span class="mobile-nav-toggle-bar"></span> <span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span> <span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span> <span class="mobile-nav-toggle-bar"></span>
</a> </a>
<a id="mobile-search-btn" class="st-search-launcher"></a>
</div> </div>
</header> </header>
\ No newline at end of file
<article class="article post" itemscope itemtype="http://schema.org/Article"> <article class="article post" itemscope itemtype="http://schema.org/Article">
<header class="article-header"> <header class="article-header">
{% if is_post() %} {% if is_post() %}
<h1 class="article-title" itemprop="name" data-swiftype-name="title" data-swiftype-type="string">{{ post.title }}</h1> <h1 class="article-title" itemprop="name">{{ post.title }}</h1>
{% else %} {% else %}
<h1> <h1>
<a href="{{ url_for(post.path) }}" class="article-title" itemprop="name">{{ post.title }}</a> <a href="{{ url_for(post.path) }}" class="article-title" itemprop="name">{{ post.title }}</a>
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
{% endif %} {% endif %}
<a href="{{ url_for(post.path) }}" class="article-date">{{ time_tag(post.date) }}</a> <a href="{{ url_for(post.path) }}" class="article-date">{{ time_tag(post.date) }}</a>
</header> </header>
<div class="article-content" itemprop="articleBody" data-swiftype-name="body" data-swiftype-type="text"> <div class="article-content" itemprop="articleBody">
{{ page_anchor(post.content) }} {{ page_anchor(post.content) }}
</div> </div>
{{ partial('partial/comment') }} {{ partial('partial/comment') }}
</article> </article>
\ No newline at end of file
...@@ -7,14 +7,16 @@ logo-size = 50px ...@@ -7,14 +7,16 @@ logo-size = 50px
padding: header-padding-normal 0 padding: header-padding-normal 0
@media print @media print
display: none display: none
.home &
padding: header-padding-max 0
#header-inner #header-inner
position: relative display: flex
flex-flow: row nowrap
align-items: center
@media mq-mobile
justify-content: center
#logo-wrap #logo-wrap
text-align: center flex: 0 logo-size
#logo #logo
hide-text() hide-text()
...@@ -22,20 +24,15 @@ logo-size = 50px ...@@ -22,20 +24,15 @@ logo-size = 50px
width: logo-size width: logo-size
height: logo-size height: logo-size
background-size: @width @height background-size: @width @height
display: inline-block display: block
@media mq-normal
float: left
#main-nav #main-nav
display: none display: none
float: left flex: 1 auto
padding-left: 20px padding-left: 20px
@media mq-normal @media mq-normal
display: block display: block
.main-nav-item
float: left
.main-nav-link .main-nav-link
color: #fff color: #fff
text-decoration: none text-decoration: none
...@@ -44,26 +41,33 @@ logo-size = 50px ...@@ -44,26 +41,33 @@ logo-size = 50px
transition: 0.2s transition: 0.2s
font-family: font-title font-family: font-title
text-transform: uppercase text-transform: uppercase
display: block display: inline-block
padding: 0 20px padding: 0 20px
&:hover &:hover
opacity: 1 opacity: 1
color: color-link-hover color: color-link-hover
#search-btn-wrap #search-input-wrap
display: none display: none
float: right
margin-right: 15px margin-right: 15px
@media mq-normal @media mq-normal
display: block display: block
#search-btn #search-input
cursor: pointer background: none
border-bottom: 1px solid color-gray
font-size: inherit
font-family: font-title
padding: 0.5em 0
color: #fff
outline: none
transition: border-color 0.2s
&:focus
border-bottom-color: color-link-hover
#lang-select-wrap #lang-select-wrap
display: none display: none
position: relative position: relative
float: right
@media mq-normal @media mq-normal
display: block display: block
...@@ -85,4 +89,4 @@ logo-size = 50px ...@@ -85,4 +89,4 @@ logo-size = 50px
width: 100% width: 100%
height: 100% height: 100%
-webkit-appearance: menulist-button -webkit-appearance: menulist-button
font-size: inherit font-size: inherit
\ No newline at end of file
...@@ -64,40 +64,6 @@ lang-select-height = 40px ...@@ -64,40 +64,6 @@ lang-select-height = 40px
.mobile-nav-on & .mobile-nav-on &
transform: rotate(-45deg) transform: rotate(-45deg)
#mobile-search-btn
position: absolute
top: 0
bottom: 0
right: gutter-width
margin: auto
width: toggle-width
height: @width
transition: 0.2s
opacity: 0.5
&:before, &:after
content: ""
position: absolute
&:before
width: 18px
height: @width
border-radius: 50%
border: toggle-line solid #fff
top: 0
left: 0
&:after
width: 9px
height: toggle-line
background: #fff
top: 15px
right: 0
border-radius: toggle-line
transform: rotate(45deg)
transform-origin: 0
&:active
opacity: 1
@media mq-normal
display: none
.mobile-nav-link .mobile-nav-link
color: #fff color: #fff
text-decoration: none text-decoration: none
...@@ -167,4 +133,4 @@ lang-select-height = 40px ...@@ -167,4 +133,4 @@ lang-select-height = 40px
.mobile-nav-on & .mobile-nav-on &
opacity: 0.7 opacity: 0.7
transform: translateX(-100%) transform: translateX(-100%)
transition: opacity transition-duration transition: opacity transition-duration
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment