forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary:It adds a list of article with pagination. I tested with 6 and 7 articles with perPage = 2 to make sure that there weren't any off by one errors. Closes jestjs#792 Differential Revision: D3043450 fb-gh-sync-id: df1bf2f347cd52ddc533ac2fe5690ce7a38c5c67 shipit-source-id: df1bf2f347cd52ddc533ac2fe5690ce7a38c5c67
- Loading branch information
Showing
5 changed files
with
89 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @providesModule BlogPageLayout | ||
* @jsx React.DOM | ||
*/ | ||
|
||
var BlogPost = require('BlogPost'); | ||
var BlogSidebar = require('BlogSidebar'); | ||
var MetadataBlog = require('MetadataBlog'); | ||
var React = require('React'); | ||
var Site = require('Site'); | ||
|
||
var BlogPageLayout = React.createClass({ | ||
getPageURL: function(page) { | ||
var url = '/jest/blog/'; | ||
if (page > 0) { | ||
url += 'page' + (page + 1) + '/'; | ||
} | ||
return url + '#content'; | ||
}, | ||
|
||
render: function() { | ||
var perPage = this.props.metadata.perPage; | ||
var page = this.props.metadata.page; | ||
return ( | ||
<Site | ||
section="blog" | ||
title="Blog"> | ||
<section className="content wrap documentationContent"> | ||
<BlogSidebar /> | ||
<div className="inner-content"> | ||
{MetadataBlog.files | ||
.slice(page * perPage, (page + 1) * perPage) | ||
.map((post) => { | ||
return <BlogPost post={post} content={post.content} /> | ||
}) | ||
} | ||
<div className="docs-prevnext"> | ||
{page > 0 && | ||
<a className="docs-prev" href={this.getPageURL(page - 1)}>← Prev</a>} | ||
{MetadataBlog.files.length > (page + 1) * perPage && | ||
<a className="docs-next" href={this.getPageURL(page + 1)}>Next →</a>} | ||
</div> | ||
</div> | ||
</section> | ||
</Site> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = BlogPageLayout; |
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