Only show 'Read More' button on blog list page when post has <!-- truncate --> token (#161)

* Only show 'Read More' button on blog list page when the text includes a <truncate> token

* Remove console.log
This commit is contained in:
Eric Nakagawa 2017-10-24 13:46:42 -07:00 committed by Joel Marcey
parent a5320dbd36
commit c2243a3c20
2 changed files with 19 additions and 24 deletions

View file

@ -12,36 +12,35 @@ const React = require("react");
class BlogPost extends React.Component {
renderContent() {
let content = this.props.content;
let hasSplit = false;
if (content.split("<!--truncate-->").length > 1) {
hasSplit = (
<div className="read-more">
<a
className="button"
href={this.props.config.baseUrl + "blog/" + this.props.post.path}>
Read More
</a>
</div>
);
}
if (this.props.truncate) {
content = content.split("<!--truncate-->")[0];
return (
<article className="post-content">
<Marked>
{content}
</Marked>
<div className="read-more">
<a
className="button"
href={this.props.config.baseUrl + "blog/" + this.props.post.path}
>
Read More
</a>
</div>
<Marked>{content}</Marked>
{hasSplit}
</article>
);
}
return (
<Marked>
{content}
</Marked>
);
return <Marked>{content}</Marked>;
}
renderAuthorPhoto() {
const post = this.props.post;
const className = "authorPhoto" + ((post.author && post.authorTitle)
? " authorPhoto-big"
: "");
const className =
"authorPhoto" +
(post.author && post.authorTitle ? " authorPhoto-big" : "");
if (post.authorFBID) {
return (
<div className={className}>
@ -60,9 +59,7 @@ class BlogPost extends React.Component {
return (
<div className={className}>
<a href={post.authorURL} target="_blank">
<img
src={post.authorImage}
/>
<img src={post.authorImage} />
</a>
</div>
);