Skip to content

Commit

Permalink
feat: include series in search
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperDramsch committed Aug 23, 2024
1 parent 579919b commit afbfafd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
34 changes: 17 additions & 17 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ social:

languages:
- en
- es
- de
# - es
# - de

exclude_from_localizations:
- 'static'
Expand Down Expand Up @@ -81,18 +81,18 @@ page_gen:
dir: 'conference'
name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')+"-"+record['year'].to_s
title_expr: record['conference']+" "+record['year'].to_s+" Conference Deadlines"
- data: 'legacy'
template: 'summary'
dir: 'series'
name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')
title_expr: record['conference']+" "+"Conference Summary"
- data: 'archive'
template: 'summary'
dir: 'series'
name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')
title_expr: record['conference']+" "+"Conference Summary"
- data: 'conferences'
template: 'summary'
dir: 'series'
name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')
title_expr: record['conference']+" "+"Conference Summary"
# - data: 'legacy'
# template: 'summary'
# dir: 'series'
# name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')
# title_expr: record['conference']+" "+"Conference Summary"
# - data: 'archive'
# template: 'summary'
# dir: 'series'
# name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')
# title_expr: record['conference']+" "+"Conference Summary"
# - data: 'conferences'
# template: 'summary'
# dir: 'series'
# name_expr: record['conference'].downcase.strip.gsub(' ', '-').gsub(/[^\p{L}]+/, '-')
# title_expr: record['conference']+" "+"Conference Summary"
22 changes: 19 additions & 3 deletions _pages/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,35 @@
"url": "{{ post.url | xml_escape }}",
"place": "",
"subs": "",
"link": ""
"link": "",
"alt_name": ""
},
{% endfor %}
{% assign confs = site.data.archive | concat: site.data.conferences | concat: site.data.legacy | sort: "year" | reverse %}
{% assign series = confs | group_by: "conference" | sort: "name" %}

{% for conf in series %}
"{{ conf.name | slugify: 'latin' }}": {
"title": "{{ conf.name | xml_escape }}",
"content": "{{ conf.name | xml_escape }}",
"date": "{{conf.items[0].year}}",
"url": "{{site.baseurl}}/series/{{conf.name | slugify: 'latin'}}/",
"place": "{{ conf.items[0].place | xml_escape }}",
"subs": "{{ conf.items[0].sub }}",
"link": "{{ conf.items[0].link }}",
"alt_name": "{{ conf.items[0].alt_name }}"
},
{% endfor %}
{% for conf in confs %}
"{{ conf.conference | slugify: 'latin' }}-{{ conf.year }}": {
"title": "{{ conf.conference | xml_escape }} {{ conf.year | xml_escape }}",
"content": "{{ conf.conference | xml_escape }} {{ conf.year | xml_escape }}",
"date": "{%- translate_file dates/pretty_dates.html -%}",
"url": "{{site.baseurl}}/{% tl conference %}/{{ conf.conference | slugify: 'latin' }}-{{ conf.year }}",
"url": "{{site.baseurl}}/conference/{{ conf.conference | slugify: 'latin' }}-{{ conf.year }}",
"place": "{{ conf.place | xml_escape }}",
"subs": "{{ conf.sub }}",
"link": "{{ conf.link }}"
"link": "{{ conf.link }}",
"alt_name": "{{ conf.alt_name }}"
}
{% unless forloop.last %},{% endunless %}
{% endfor %}
Expand Down
6 changes: 5 additions & 1 deletion static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
this.field('title', { boost: 10 });
this.field('date');
this.field('content');
this.field('place');
this.field('alt_name', { boost: 10 });

for (var key in window.store) {
// Add the data to lunr
Expand All @@ -116,11 +118,13 @@
title: window.store[key].title,
date: window.store[key].date,
content: window.store[key].content,
place: window.store[key].place,
alt_name: window.store[key].alt_name,
});
}
});

var results = idx.search(searchTerm + '^30 *' + searchTerm + '*'); // Get lunr to perform a search
var results = idx.search(searchTerm + '^30 ' + searchTerm + '~1 *' + searchTerm + '*'); // Get lunr to perform a search
displaySearchResults(results, window.store);
}
})();

0 comments on commit afbfafd

Please sign in to comment.