Skip to content

fix(doc): All wigdets in docs are not anymore linked together #fix #446 #452

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

Merged
merged 1 commit into from
Nov 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ If you already have a JavaScript build system, you can use **instantsearch.js**
### Initialization

<div class="code-box">
<div class="code-sample-snippet">
<div class="code-sample-snippet config">
{% highlight javascript %}
var search = instantsearch({
appId: '$appId',
Expand Down Expand Up @@ -171,7 +171,7 @@ Most widgets requires you to configure the DOM element they will use to display
### Start

<div class="code-box">
<div class="code-sample-snippet last">
<div class="code-sample-snippet start">
{% highlight javascript %}
search.start();
{% endhighlight %}
Expand Down
18 changes: 12 additions & 6 deletions docs/js/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
function search() {
function t(tmpl, vars) {
Object.keys(vars).forEach(function(k) {
tmpl = tmpl.replace('$' + k, vars[k]);
tmpl = tmpl.replace(new RegExp('\\$' + k, 'g'), vars[k]);
});
return tmpl;
}
Expand All @@ -15,11 +15,17 @@
apiKey: '6be0576ff61c053d5f9a3225e2a90f76',
indexName: 'instant_search'
};
var codeSnippets = q('.code-sample-snippet:not(.last):not(.ignore)');
var lastSnippets = q('.code-sample-snippet.last');
var source = codeSnippets
.concat(lastSnippets)
.map(function(d) {return d.textContent;});
var codeSnippets = q('.code-sample-snippet:not(.start):not(.config):not(.ignore)');
var configSnippet = q('.code-sample-snippet.config')[0];
var startSnippet = q('.code-sample-snippet.start')[0];

var source = codeSnippets.map(function(snippet) {
var functionBody = [configSnippet, snippet, startSnippet]
.map(function(e) { return e.textContent; })
.join(';');
return "(function() {" + functionBody + "})();";
});

source = t(source.join('\n'), constants);
eval(source);
}
Expand Down