Skip to content

Commit

Permalink
Merge pull request #424 from electricbookworks/web-vs-app-search-indexes
Browse files Browse the repository at this point in the history
Generate separate web and app search indexes
  • Loading branch information
arthurattwell committed Nov 25, 2019
2 parents 957e235 + 958828b commit 23c4823
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 8 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ exclude:
- .sass-cache
# Included as-is in other files, no need to process
- /assets/js/annotation.js
- /assets/js/search-store.js
- /assets/js/elasticlunr.min.js
- /assets/js/elasticlunr-setup.js
# Files for formats we're not building here
- /assets/profiles
- /*/package.opf
Expand Down
6 changes: 6 additions & 0 deletions _configs/_config.app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ exclude:
- package.json
- package-lock.json
- CNAME
- .sass-cache
# Included as-is in other files, no need to process
- /assets/js/annotation.js
- /assets/js/search-store.js
- /assets/js/elasticlunr.min.js
- /assets/js/elasticlunr-setup.js
# Things we don't need for an app
- assets/profiles
- /*/package.opf
Expand Down
2 changes: 1 addition & 1 deletion _includes/close-body.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% if site.output == "web" or site.output == "app" %}
{% if is-project-search or is-book-search %}
<script src="{{ path-to-root-directory }}assets/js/search-engine.js"></script>
<script src="{{ path-to-root-directory }}assets/js/search-index.js"></script>
<script src="{{ path-to-root-directory }}assets/js/search-index-{{ site.output }}.js"></script>
<script src="{{ path-to-root-directory }}assets/js/search-results.js"></script>
{% endif %}
{% endif %}
Expand Down
7 changes: 4 additions & 3 deletions assets/js/render-search-index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# Jekyll processes this file to generate the array of URLs.
# Then the output script passes this to phantomjs,
# which generates the search index as search-index.js.
# which generates the search index as search-index-web.js
# or search-index-app.js, depending on current output format.
layout: null
---

Expand Down Expand Up @@ -73,8 +74,8 @@ function process() {
count = count + 1;

} else {
console.log('Writing search-index.js...');
fs.write('../../../assets/js/search-index.js', index, 'w');
console.log('Writing search-index-{{ site.output }}.js...');
fs.write('../../../assets/js/search-index-{{ site.output }}.js', index, 'w');
console.log('Done.');
page.close();
phantom.exit();
Expand Down
255 changes: 255 additions & 0 deletions assets/js/search-index-app.js

Large diffs are not rendered by default.

Loading

0 comments on commit 23c4823

Please sign in to comment.