Skip to content

Commit

Permalink
Add lunr-gr.js and fix lunr-en.js (mmistakes#1445)
Browse files Browse the repository at this point in the history
* Remove Lunr trimmer & bring back colons
* Add Greek Stemmer
* Translate `search_placeholder_text` and `results_found` to Greek
  • Loading branch information
nickgarlis authored and mmistakes committed Jan 3, 2018
1 parent 81e4eae commit d8406de
Show file tree
Hide file tree
Showing 4 changed files with 566 additions and 2 deletions.
2 changes: 2 additions & 0 deletions _data/ui-text.yml
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@ gr: &DEFAULT_GR
comment_success_msg : "Ευχαριστούμε για το σχόλιό σας! Θα εμφανιστεί στην ιστοσελίδα αφού εγκριθεί."
comment_error_msg : "Λυπούμαστε, παρουσιάστηκε σφάλμα με την υποβολή σας. Παρακαλούμε βεβαιωθείτε ότι έχετε όλα τα απαιτούμενα πεδία συμπληρωμένα και δοκιμάστε ξανά."
loading_label : "Φόρτωση..."
search_placeholder_text : "Εισάγετε όρο αναζήτησης..."
results_found : "Αποτελέσματα"
gr-GR:
<<: *DEFAULT_GR

Expand Down
3 changes: 2 additions & 1 deletion _includes/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
{% endif %}

{% if site.search == true or page.layout == 'search' %}
{% assign lang = site.locale | slice: 0,2 | default: "en" %}
<script src="{{ '/assets/js/lunr.min.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/lunr-en.js' | absolute_url }}"></script>
<script src="{{ '/assets/js/lunr-' | append: lang | append: '.js' | absolute_url }}"></script>
{% endif %}

{% include analytics.html %}
Expand Down
4 changes: 3 additions & 1 deletion assets/js/lunr-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ var idx = lunr(function () {
this.field('tags')
this.ref('id')

this.pipeline.remove(lunr.trimmer)

{% assign count = 0 %}
{% for c in site.collections %}
{% assign docs = c.docs | where_exp:'doc','doc.search != false' %}
Expand Down Expand Up @@ -56,7 +58,7 @@ var store = [
$(document).ready(function() {
$('input#search').on('keyup', function () {
var resultdiv = $('#results');
var query = $(this).val().toLowerCase().replace(":", "");
var query = $(this).val().toLowerCase();
var result =
idx.query(function (q) {
query.split(lunr.tokenizer.separator).forEach(function (term) {
Expand Down
Loading

0 comments on commit d8406de

Please sign in to comment.