mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-14 11:32:48 +00:00
too many changes - load posts now
This commit is contained in:
@@ -1,39 +1,39 @@
|
||||
import React from 'react';
|
||||
import Link from 'react-router';
|
||||
import {Link} from 'react-router';
|
||||
|
||||
import '../../assets/scss/Preview.scss';
|
||||
|
||||
export default class Preview extends React.Component{
|
||||
|
||||
insertPosts(posts){
|
||||
let elements = [];
|
||||
for (let i in posts){
|
||||
elements.push(
|
||||
<div class="post" key={i}>
|
||||
<div class="date">{posts[i].date}</div>
|
||||
<div class="intro" dangerouslySetInnerHTML={this.decodeHtml(posts[i].title.toString())}></div>
|
||||
<div dangerouslySetInnerHTML={this.decodeHtml(posts[i].intro.toString())}></div>
|
||||
<p><a class="link" href="#">continue reading...</a></p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return elements;
|
||||
insertPosts(posts){
|
||||
let elements = [];
|
||||
for (let i in posts){
|
||||
elements.push(
|
||||
<div class="post" key={i}>
|
||||
<div class="date">
|
||||
{posts[i].date}
|
||||
</div>
|
||||
<h2 class="intro" >{posts[i].title.toString()}</h2>
|
||||
<p>{posts[i].intro.toString()}</p>
|
||||
<p>
|
||||
<Link class="link" to={`/post/${posts[i].category}/${posts[i].filename}`}>
|
||||
continue reading...
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
decodeHtml(html) {
|
||||
var txt = document.createElement("textarea");
|
||||
txt.innerHTML = html;
|
||||
return {__html : txt.value};
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
render(){
|
||||
const posts = this.props.posts;
|
||||
render(){
|
||||
const posts = this.props.posts;
|
||||
|
||||
return (
|
||||
<div class="Preview">
|
||||
{posts.length > 0 ? this.insertPosts(posts): ""}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div class="Preview">
|
||||
{posts.length > 0 ? this.insertPosts(posts): ""}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user