-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from contentstack/staging
Staging
- Loading branch information
Showing
34 changed files
with
8,763 additions
and
1,466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React from 'react'; | ||
import moment from 'moment'; | ||
import parse from 'html-react-parser'; | ||
import Link from 'next/link'; | ||
|
||
function BlogList({ bloglist }) { | ||
let body = typeof bloglist.body === 'string' && bloglist.body.substr(0, 300); | ||
const stringLength = body.lastIndexOf(' '); | ||
body = `${body.substr(0, Math.min(body.length, stringLength))}...`; | ||
return ( | ||
<div className='blog-list'> | ||
{bloglist.featured_image && ( | ||
<Link href={bloglist.url}> | ||
<a> | ||
<img | ||
className='blog-list-img' | ||
src={bloglist.featured_image.url} | ||
alt='blog img' | ||
{...bloglist.featured_image.$?.url} | ||
/> | ||
</a> | ||
</Link> | ||
)} | ||
<div className='blog-content'> | ||
{bloglist.title && ( | ||
<Link href={bloglist.url}> | ||
<a> | ||
<h3 {...bloglist.$?.title}>{bloglist.title}</h3> | ||
</a> | ||
</Link> | ||
)} | ||
<p> | ||
<strong {...bloglist.$?.date}> | ||
{moment(bloglist.date).format('ddd, MMM D YYYY')} | ||
</strong> | ||
,{" "} | ||
<strong {...bloglist.author[0].$?.title}> | ||
{bloglist.author[0].title} | ||
</strong> | ||
</p> | ||
<div {...bloglist.$?.body}>{parse(body)}</div> | ||
{bloglist.url ? ( | ||
<Link href={bloglist.url}> | ||
<a> | ||
<span>{'Read more -->'}</span> | ||
</a> | ||
</Link> | ||
) : ( | ||
'' | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default BlogList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.