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.
Initial implementation of a blog support
Summary:This adds blog post rendering, left nav with the list of blog posts, highlighting the currently selected blog post and highlighting the header links. I cp all the React blog posts in order to test it out, working great. Missing pieces: - I haven't implemented a listing of all blog posts, the header link opens the most recent one. - I haven't implemented truncation of the links on the left and the all page Those are needed when we'll have > 1 blog post, which is not now :) bypass-lint ![screen shot 2016-03-02 at 3 55 09 pm](https://cloud.githubusercontent.com/assets/197597/13480193/011abff8-e091-11e5-8421-677217f383ff.png) Closes jestjs#760 Differential Revision: D3006427 fb-gh-sync-id: 0e635247732f6187f9255ea92d59701f1a467af4 shipit-source-id: 0e635247732f6187f9255ea92d59701f1a467af4
- Loading branch information
Showing
4 changed files
with
190 additions
and
52 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,66 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
* | ||
* @providesModule BlogPostLayout | ||
* @jsx React.DOM | ||
*/ | ||
|
||
var Marked = require('Marked'); | ||
var MetadataBlog = require('MetadataBlog'); | ||
var React = require('React'); | ||
var Site = require('Site'); | ||
|
||
var BlogPostLayout = React.createClass({ | ||
renderSidebar: function(current) { | ||
return ( | ||
<div className="nav-docs"> | ||
<div className="nav-docs-section"> | ||
<h3>Recent Posts</h3> | ||
<ul> | ||
{MetadataBlog.files.map(function(post) { | ||
return ( | ||
<li key={post.path}> | ||
<a | ||
className={current.title === post.title ? 'active' : ''} | ||
href={'/jest/blog/' + post.path}> | ||
{post.title} | ||
</a> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
</div> | ||
</div> | ||
); | ||
}, | ||
|
||
render: function() { | ||
var metadata = this.props.metadata; | ||
var content = this.props.children; | ||
|
||
var match = metadata.path.match(/([0-9]+)\/([0-9]+)\/([0-9]+)/); | ||
// Because JavaScript sucks at date handling :( | ||
var year = match[1]; | ||
var month = [ | ||
'January', 'February', 'March', 'April', 'May', 'June', 'July', | ||
'August', 'September', 'October', 'November', 'December' | ||
][parseInt(match[2], 10) + 1]; | ||
var day = parseInt(match[3], 10); | ||
|
||
return ( | ||
<Site section="blog"> | ||
<section className="content wrap documentationContent"> | ||
{this.renderSidebar(this.props.metadata)} | ||
<div className="inner-content"> | ||
<h1>{metadata.title}</h1> | ||
<p className="meta">{month} {day}, {year} by {metadata.author}</p> | ||
<hr /> | ||
<Marked>{content}</Marked> | ||
</div> | ||
</section> | ||
</Site> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = BlogPostLayout; |
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