Permalink
Browse files

Try algolia search

  • Loading branch information...
tommy351 committed Dec 29, 2015
1 parent a7e0d83 commit a3961d9cd3958141cebf8f02c13c9849fe7cf421
View
@@ -24,6 +24,8 @@ deploy:
disqus_shortname: hexojs
google_analytics: UA-4910098-10
fb_admins: 100000247608790
swiftype_key: EwN4HMy_KMxTK_GMjV1z
algolia:
api_key: c3d5d4c995b5e0c2ffb5623900279a66
index_name: hexo
twitter: hexojs
github: hexojs/hexo
github: hexojs/hexo
View
@@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.1.1"
"version": "3.2.0-beta.2"
},
"scripts": {
"build": "hexo generate && gulp",
@@ -40,4 +40,4 @@
"optionalDependencies": {
"hexo-browsersync": "^0.2.0"
}
}
}
View
@@ -74,9 +74,7 @@ hexo.extend.helper.register('header_menu', function(className){
_.each(menu, function(path, title){
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 += '</li>';
});
return result;
@@ -154,4 +152,4 @@ hexo.extend.helper.register('disqus_lang', function(){
var data = this.site.data.languages[lang];
return data.disqus_lang || lang;
});
});
@@ -6,10 +6,10 @@
<div class="article">
<div class="inner">
<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>
</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) }}
</div>
<footer class="article-footer">
@@ -31,4 +31,4 @@
{{ partial('partial/sidebar') }}
</div>
</div>
</div>
</div>
@@ -12,12 +12,12 @@
{{ js('js/plugins') }}
<!-- endbuild -->
{% endif %}
<!-- Swiftype -->
<!-- Algolia -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>
<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','https://s.swiftypecdn.com/install/v2/st.js','_st');
_st('install','{{ config.swiftype_key }}','2.0.0');
</script>
docsearch({
apiKey: '{{ config.algolia.api_key }}',
indexName: '{{ config.algolia.index_name }}',
inputSelector: '#search-input'
});
</script>
@@ -33,15 +33,14 @@
<!-- endbuild -->
<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://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css">
<!-- RSS -->
{{ feed_tag('atom.xml') }}
<!-- Open Graph -->
{{ open_graph({
fb_admins: config.fb_admins,
twitter_site: config.twitter
}) }}
<!-- Swiftype -->
<meta name="st:title" content="{{ page.title || config.title }}">
<!-- Google Analytics -->
{{ partial('google_analytics') }}
</head>
</head>
@@ -4,13 +4,12 @@
<a href="{{ url_for_lang('') }}" id="logo">Hexo</a>
</h1>
<nav id="main-nav">
<ul>
{{ header_menu('main-nav') }}
<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>
{{ header_menu('main-nav') }}
<a href="https://github.com/{{ config.github }}" class="main-nav-link"><i class="fa fa-github-alt"></i></a>
</nav>
<div id="search-input-wrap">
<input type="search" id="search-input" placeholder="Search...">
</div>
<div id="lang-select-wrap">
<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() }}">
@@ -19,14 +18,10 @@
{% endfor %}
</select>
</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">
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
</a>
<a id="mobile-search-btn" class="st-search-launcher"></a>
</div>
</header>
</header>
@@ -1,16 +1,16 @@
<article class="article post" itemscope itemtype="http://schema.org/Article">
<header class="article-header">
{% 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 %}
<h1>
<a href="{{ url_for(post.path) }}" class="article-title" itemprop="name">{{ post.title }}</a>
</h1>
{% endif %}
<a href="{{ url_for(post.path) }}" class="article-date">{{ time_tag(post.date) }}</a>
</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) }}
</div>
{{ partial('partial/comment') }}
</article>
</article>
@@ -7,35 +7,32 @@ logo-size = 50px
padding: header-padding-normal 0
@media print
display: none
.home &
padding: header-padding-max 0
#header-inner
position: relative
display: flex
flex-flow: row nowrap
align-items: center
@media mq-mobile
justify-content: center
#logo-wrap
text-align: center
flex: 0 logo-size
#logo
hide-text()
background: url("/logo.svg")
width: logo-size
height: logo-size
background-size: @width @height
display: inline-block
@media mq-normal
float: left
display: block
#main-nav
display: none
float: left
flex: 1 auto
padding-left: 20px
@media mq-normal
display: block
.main-nav-item
float: left
.main-nav-link
color: #fff
text-decoration: none
@@ -44,26 +41,33 @@ logo-size = 50px
transition: 0.2s
font-family: font-title
text-transform: uppercase
display: block
display: inline-block
padding: 0 20px
&:hover
opacity: 1
color: color-link-hover
#search-btn-wrap
#search-input-wrap
display: none
float: right
margin-right: 15px
@media mq-normal
display: block
#search-btn
cursor: pointer
#search-input
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
display: none
position: relative
float: right
@media mq-normal
display: block
@@ -85,4 +89,4 @@ logo-size = 50px
width: 100%
height: 100%
-webkit-appearance: menulist-button
font-size: inherit
font-size: inherit
@@ -64,40 +64,6 @@ lang-select-height = 40px
.mobile-nav-on &
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
color: #fff
text-decoration: none
@@ -167,4 +133,4 @@ lang-select-height = 40px
.mobile-nav-on &
opacity: 0.7
transform: translateX(-100%)
transition: opacity transition-duration
transition: opacity transition-duration

1 comment on commit a3961d9

@Xuanwo

This comment has been minimized.

Contributor

Xuanwo commented on a3961d9 Dec 30, 2015

When I type deploy in the search box, there is no reponse, what happened ?

I meet an error in Chrome console that : Failed to load resource: the server responded with a status of 403 (Forbidden), with the address https://bh4d9od16a-dsn.algolia.net/1/indexes/*/queries?x-algolia-api-key=c3d5d4c995b5e0c2ffb5623900279a66&x-algolia-application-id=BH4D9OD16A&x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%203.10.2%3Bdocsearch.js%201.0.2

Please sign in to comment.