Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize local search #64

Merged
merged 16 commits into from
Jul 29, 2020
2 changes: 1 addition & 1 deletion layout/_partials/search/localsearch.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocapitalize="off"
<input autocomplete="off" autocapitalize="off" maxlength="80"
placeholder="{{ __('search.placeholder') }}" spellcheck="false"
type="search" class="search-input">
</div>
Expand Down
16 changes: 9 additions & 7 deletions scripts/helpers/next-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const { parse } = require('url');
*/
hexo.extend.helper.register('next_config', function() {
const { config, theme, next_version } = this;
config.algolia = config.algolia || {};
const exportConfig = {
hostname : parse(config.url).hostname || config.url,
root : config.root,
Expand All @@ -24,19 +23,22 @@ hexo.extend.helper.register('next_config', function() {
lazyload : theme.lazyload,
pangu : theme.pangu,
comments : theme.comments,
algolia : {
motion : theme.motion,
prism : config.prismjs.enable && !config.prismjs.preprocess
};
if (theme.algolia_search && theme.algolia_search.enable) {
config.algolia = config.algolia || {};
exportConfig.algolia = {
appID : config.algolia.applicationID,
apiKey : config.algolia.apiKey,
indexName: config.algolia.indexName,
hits : theme.algolia_search.hits,
labels : theme.algolia_search.labels
},
localsearch: theme.local_search,
motion : theme.motion,
prism : config.prismjs.enable && !config.prismjs.preprocess
};
};
}
if (config.search) {
exportConfig.path = config.search.path;
exportConfig.localsearch = theme.local_search;
}
return `<script class="hexo-configurations">
var NexT = window.NexT || {};
Expand Down
13 changes: 7 additions & 6 deletions source/css/_common/components/third-party/search.styl
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@ if (hexo-config('local_search.enable')) {
font-weight: bold;
}

.search-keyword {
border-bottom: 1px dashed $red;
color: $red;
font-weight: bold;
}

#search-result {
display: flex;
height: calc(100% - 55px);
Expand All @@ -172,4 +166,11 @@ if (hexo-config('local_search.enable')) {
margin: auto;
}
}

mark.search-keyword {
background: transparent;
border-bottom: 1px dashed $red;
color: $red;
font-weight: bold;
}
}
Loading