mirror of
https://github.com/flarum/core.git
synced 2025-05-06 15:35:38 +02:00
Fix incorrect highlighting of post excerpts
This commit is contained in:
parent
8b162344cd
commit
16c714012f
@ -12,14 +12,14 @@ export default class PostPreview extends Component {
|
|||||||
var excerpt = post.contentPlain();
|
var excerpt = post.contentPlain();
|
||||||
var start = 0;
|
var start = 0;
|
||||||
|
|
||||||
if (highlight) {
|
if (this.props.highlight) {
|
||||||
var regexp = new RegExp(this.props.highlight, 'gi');
|
var regexp = new RegExp(this.props.highlight, 'gi');
|
||||||
start = Math.max(0, excerpt.search(regexp) - 100);
|
start = Math.max(0, excerpt.search(regexp) - 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
excerpt = (start > 0 ? '...' : '')+excerpt.substring(start, start + 200)+(excerpt.length > start + 200 ? '...' : '');
|
excerpt = (start > 0 ? '...' : '')+excerpt.substring(start, start + 200)+(excerpt.length > start + 200 ? '...' : '');
|
||||||
|
|
||||||
if (highlight) {
|
if (this.props.highlight) {
|
||||||
excerpt = highlight(excerpt, regexp);
|
excerpt = highlight(excerpt, regexp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user