1
0
mirror of https://github.com/flarum/core.git synced 2025-05-02 13:43:39 +02:00

Only show search suggestion excerpt if we have it

We won’t have it if we didn’t do a fulltext search
This commit is contained in:
Toby Zerner 2015-06-26 12:08:23 +09:30
parent 35c05862a4
commit 9e6ad1f244
2 changed files with 5 additions and 6 deletions

View File

@ -24,11 +24,12 @@ export default class DiscussionsSearchResults {
config: m.route
})),
(this.results[string] && this.results[string].length) ? this.results[string].map(discussion => {
var post = discussion.relevantPosts()[0];
var relevantPosts = discussion.relevantPosts();
var post = relevantPosts && relevantPosts[0];
return m('li.discussion-search-result', {'data-index': 'discussions'+discussion.id()},
m('a', { href: app.route.discussion(discussion, post.number()), config: m.route },
m('a', { href: app.route.discussion(discussion, post && post.number()), config: m.route },
m('div.title', highlight(discussion.title(), string)),
m('div.excerpt', highlight(truncate(post.contentPlain(), 100), string))
post ? m('div.excerpt', highlight(truncate(post.contentPlain(), 100), string)) : ''
)
);
}) : ''

View File

@ -68,10 +68,8 @@
}
.discussion-search-result {
& .title {
margin-bottom: 3px;
}
& .excerpt {
margin-top: 3px;
color: @fl-body-muted-color;
font-size: 11px;
}