Skip to content

Commit

Permalink
add algolia DocSearch
Browse files Browse the repository at this point in the history
- closes #73
- uses Algolia free plan with configuration at
  https://github.com/algolia/docsearch-configs/blob/master/configs/mdanalysis.json
- Algolia index is updated every 24 hours.
- NOTE: needed to set site.baseurl to empty to make local testing work;
  according to https://byparker.com/blog/2014/clearing-up-confusion-around-baseurl/
  we do NOT need to use it.

  When running locally my installation failed to load local js and only after
  setting baseurl to empty would it work.
  (See #16 (comment))
  • Loading branch information
orbeckst committed May 1, 2018
1 parent 8588181 commit decc4b2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ name: MDAnalysis
tagline: A Python package for the analysis of molecular dynamics simulations.
description: A Python package for the analysis of molecular dynamics simulations.
url: https://www.mdanalysis.org
baseurl: /
# leave baseurl empty,
# see https://github.com/MDAnalysis/MDAnalysis.github.io/issues/16#issuecomment-385572553
baseurl:
author:
name: The MDAnalysis Team
url: https://twitter.com/mdanalysis
Expand Down Expand Up @@ -65,3 +67,6 @@ twitter:
url: https://twitter.com/mdanalysis


algolia:
index_name: mdanalysis
read_only_api_key: 307d780013d06fdde7a4eae462db0e74
12 changes: 12 additions & 0 deletions _includes/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


<!-- Algolia DocSearch https://community.algolia.com/docsearch/ -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script type="text/javascript"> docsearch({
apiKey: '{{ site.algolia.read_only_api_key }}',
indexName: '{{ site.algolia.index_name }}',
inputSelector: 'input[type=text]',
debug: true // Set debug to true if you want to inspect the dropdown
});
</script>

3 changes: 3 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
anchors.add('h1, h2, h3, h4, h5, h6');
});
</script>

<!-- Algolia DocSearch https://community.algolia.com/docsearch/ -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />

<!-- Google Analytics -->
<script>
Expand Down
2 changes: 2 additions & 0 deletions _includes/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ <h1>
<p class="lead">{{ site.description }}</p>
</div>

<input type="text" class="searchbox" autocomplete="off" name="query" placeholder="Search mdanalysis.org..." />

<nav class="sidebar-nav">
<a class="sidebar-nav-item{% if page.url == site.baseurl %} active{% endif %}" href="{{ site.baseurl }}/">Home</a>

Expand Down
1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
{{ content }}
</div>

{% include footer.html %}
</body>
</html>

0 comments on commit decc4b2

Please sign in to comment.