Remove blockquotes from post previews

Closes flarum/core#144
This commit is contained in:
Toby Zerner 2015-08-06 13:28:26 +09:30
parent edddeeb553
commit de42c316c0
2 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import Component from 'flarum/Component'; import Component from 'flarum/Component';
import avatar from 'flarum/helpers/avatar'; import avatar from 'flarum/helpers/avatar';
import username from 'flarum/helpers/username'; import username from 'flarum/helpers/username';
import humanTime from 'flarum/helpers/humanTime';
import highlight from 'flarum/helpers/highlight'; import highlight from 'flarum/helpers/highlight';
/** /**
@ -22,8 +21,7 @@ export default class PostPreview extends Component {
<a className="PostPreview" href={app.route.post(post)} config={m.route} onclick={this.props.onclick}> <a className="PostPreview" href={app.route.post(post)} config={m.route} onclick={this.props.onclick}>
<span className="PostPreview-content"> <span className="PostPreview-content">
{avatar(user)} {avatar(user)}
{username(user)} {username(user)}{' '}
{humanTime(post.time())}
<span className="PostPreview-excerpt">{excerpt}</span> <span className="PostPreview-excerpt">{excerpt}</span>
</span> </span>
</a> </a>

View File

@ -34,9 +34,15 @@ export function slug(string) {
* @return {String} * @return {String}
*/ */
export function getPlainContent(string) { export function getPlainContent(string) {
return $('<div/>').html(string.replace(/(<\/p>|<br>)/g, '$1 ')).text(); const dom = $('<div/>').html(string.replace(/(<\/p>|<br>)/g, '$1 &nbsp;'));
dom.find(getPlainContent.removeSelectors.join(',')).remove();
return dom.text();
} }
getPlainContent.removeSelectors = ['blockquote'];
/** /**
* Make a string's first character uppercase. * Make a string's first character uppercase.
* *