mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Search plugin should provide roles "search:results" and "search:result"
This commit is contained in:
@@ -11,10 +11,12 @@ const Result = React.createClass({
|
||||
|
||||
return (
|
||||
<div className="Search-Result">
|
||||
<h3>
|
||||
<GitBook.Link to={result.url}>{result.title}</GitBook.Link>
|
||||
</h3>
|
||||
<p>{result.body}</p>
|
||||
<GitBook.InjectedComponent matching={{ role: 'search:result' }} props={{ result }}>
|
||||
<h3>
|
||||
<GitBook.Link to={result.url}>{result.title}</GitBook.Link>
|
||||
</h3>
|
||||
<p>{result.body}</p>
|
||||
</GitBook.InjectedComponent>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -37,12 +39,14 @@ const SearchResults = React.createClass({
|
||||
|
||||
return (
|
||||
<div className="Search-ResultsContainer">
|
||||
<h1>{i18n.t('SEARCH_RESULTS_TITLE', { query, count: results.size })}</h1>
|
||||
<div className="Search-Results">
|
||||
{results.map((result, i) => {
|
||||
return <Result key={i} result={result} />;
|
||||
})}
|
||||
</div>
|
||||
<GitBook.InjectedComponent matching={{ role: 'search:results' }} props={{ results, query }}>
|
||||
<h1>{i18n.t('SEARCH_RESULTS_TITLE', { query, count: results.size })}</h1>
|
||||
<div className="Search-Results">
|
||||
{results.map((result, i) => {
|
||||
return <Result key={i} result={result} />;
|
||||
})}
|
||||
</div>
|
||||
</GitBook.InjectedComponent>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ module.exports = GitBook.createPlugin({
|
||||
dispatch(History.listen(onLocationChange));
|
||||
|
||||
// Register components
|
||||
dispatch(Components.registerComponent(SearchInput, { role: 'search:input' }));
|
||||
dispatch(Components.registerComponent(SearchResults, { role: 'search:results' }));
|
||||
dispatch(Components.registerComponent(SearchInput, { role: 'search:container:input' }));
|
||||
dispatch(Components.registerComponent(SearchResults, { role: 'search:container:results' }));
|
||||
},
|
||||
reduce: reducers,
|
||||
actions: {
|
||||
|
||||
@@ -11,7 +11,7 @@ const Page = React.createClass({
|
||||
|
||||
return (
|
||||
<div className="Page page-wrapper">
|
||||
<GitBook.InjectedComponent matching={{ role: 'search:results' }} props={this.props}>
|
||||
<GitBook.InjectedComponent matching={{ role: 'search:container:results' }} props={this.props}>
|
||||
<GitBook.InjectedComponent matching={{ role: 'page:container' }} props={this.props}>
|
||||
<GitBook.HTMLContent html={page.content} />
|
||||
</GitBook.InjectedComponent>
|
||||
|
||||
@@ -13,7 +13,7 @@ const Sidebar = React.createClass({
|
||||
|
||||
return (
|
||||
<div className="Sidebar book-summary">
|
||||
<GitBook.InjectedComponent matching={{ role: 'search:input' }} />
|
||||
<GitBook.InjectedComponent matching={{ role: 'search:container:input' }} />
|
||||
<Summary summary={summary} />
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user