FIX: Expose PG headline highlighting for all search results.

This commit is contained in:
Guo Xiang Tan 2020-08-12 16:43:47 +08:00
parent 603a4d1794
commit 808e84a856
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
4 changed files with 15 additions and 4 deletions

View File

@ -31,7 +31,16 @@
<div class="fps-topic">
<div class="topic">
<a href={{result.url}} class="search-link">
{{topic-status topic=result.topic disableActions=true}}<span class="topic-title">{{#highlight-search highlight=term}}{{html-safe result.topic.fancyTitle}}{{/highlight-search}}</span>
{{topic-status topic=result.topic disableActions=true}}
<span class="topic-title">
{{#if result.useTopicTitleHeadline}}
{{html-safe result.topicTitleHeadline}}
{{else}}
{{#highlight-search highlight=q}}
{{html-safe result.topic.fancyTitle}}
{{/highlight-search}}
{{/if}}
</span>
</a>
<div class="search-category">

View File

@ -112,7 +112,7 @@ const Post = RestModel.extend({
},
@discourseComputed("topic_title_headline")
topicTitleHead(title) {
topicTitleHeadline(title) {
return fancyTitle(title, this.siteSettings.support_mixed_text_direction);
},

View File

@ -90,7 +90,7 @@
{{topic-status topic=result.topic disableActions=true showPrivateMessageIcon=true}}
<span class="topic-title">
{{#if result.useTopicTitleHeadline}}
{{html-safe result.topicTitleHead}}
{{html-safe result.topicTitleHeadline}}
{{else}}
{{#highlight-search highlight=q}}
{{html-safe result.topic.fancyTitle}}

View File

@ -59,7 +59,9 @@ function postResult(result, link, term) {
h("span.blurb", [
dateNode(result.created_at),
h("span", " - "),
new Highlighted(result.blurb, term)
this.siteSettings.use_pg_headlines_for_excerpt
? new RawHtml({ html: `<span>${result.blurb}</span>` })
: new Highlighted(result.blurb, term)
])
);
}