mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Fix incorrect highlighting of post excerpts
This commit is contained in:
parent
f82aaa82a5
commit
2180e15757
|
@ -12,14 +12,14 @@ export default class PostPreview extends Component {
|
|||
var excerpt = post.contentPlain();
|
||||
var start = 0;
|
||||
|
||||
if (highlight) {
|
||||
if (this.props.highlight) {
|
||||
var regexp = new RegExp(this.props.highlight, 'gi');
|
||||
start = Math.max(0, excerpt.search(regexp) - 100);
|
||||
}
|
||||
|
||||
excerpt = (start > 0 ? '...' : '')+excerpt.substring(start, start + 200)+(excerpt.length > start + 200 ? '...' : '');
|
||||
|
||||
if (highlight) {
|
||||
if (this.props.highlight) {
|
||||
excerpt = highlight(excerpt, regexp);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user