Fix incorrect highlighting of post excerpts

This commit is contained in:
Toby Zerner 2015-06-10 14:42:14 +09:30
parent f82aaa82a5
commit 2180e15757

View File

@ -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);
}