Skip to content

Commit 77aee02

Browse files
committed
Introduce blog
Ported the infrastructure from jest.
1 parent 4c7c365 commit 77aee02

File tree

10 files changed

+321
-46
lines changed

10 files changed

+321
-46
lines changed

blog/2016-03-24-test.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Test
3+
author: vjeux
4+
---
5+
6+
This is a test

website/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
src/react-native/docs/**
2+
src/react-native/blog/**
23
core/metadata.js
34
*.log
45
/build/

website/core/BlogPost.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule BlogPost
10+
*/
11+
12+
'use strict';
13+
14+
var Marked = require('Marked');
15+
var React = require('React');
16+
17+
var BlogPost = React.createClass({
18+
render: function() {
19+
var post = this.props.post;
20+
var content = this.props.content;
21+
22+
var match = post.path.match(/([0-9]+)\/([0-9]+)\/([0-9]+)/);
23+
// Because JavaScript sucks at date handling :(
24+
var year = match[1];
25+
var month = [
26+
'January', 'February', 'March', 'April', 'May', 'June', 'July',
27+
'August', 'September', 'October', 'November', 'December'
28+
][parseInt(match[2], 10) - 1];
29+
var day = parseInt(match[3], 10);
30+
31+
return (
32+
<div>
33+
<h1>{post.title}</h1>
34+
<p className="meta">
35+
{month} {day}, {year} by{' '}
36+
<a href={post.authorURL} target="_blank">{post.author}</a>
37+
</p>
38+
<hr />
39+
<Marked>{content}</Marked>
40+
</div>
41+
);
42+
}
43+
});
44+
45+
module.exports = BlogPost;

website/core/BlogSidebar.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule BlogSidebar
10+
*/
11+
12+
'use strict';
13+
14+
var MetadataBlog = require('MetadataBlog');
15+
var React = require('React');
16+
17+
var BlogSidebar = React.createClass({
18+
render: function() {
19+
return (
20+
<div className="nav-docs">
21+
<div className="nav-docs-section">
22+
<h3>Recent Posts</h3>
23+
<ul>
24+
{MetadataBlog.files.map(function(post) {
25+
return (
26+
<li key={post.path}>
27+
<a
28+
className={this.props.title === post.title ? 'active' : ''}
29+
href={'/react-native/blog/' + post.path}>
30+
{post.title}
31+
</a>
32+
</li>
33+
);
34+
}.bind(this))}
35+
</ul>
36+
</div>
37+
</div>
38+
);
39+
}
40+
});
41+
42+
module.exports = BlogSidebar;

website/core/HeaderLinks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var HeaderLinks = React.createClass({
1818
{section: 'support', href: 'support.html', text: 'Support'},
1919
{section: 'newsletter', href: 'http://reactnative.cc', text: 'Newsletter'},
2020
{section: 'showcase', href: 'showcase.html', text: 'Showcase'},
21+
{section: 'blog', href: 'blog/', text: 'Blog'},
2122
],
2223
linksExternal: [
2324
{section: 'github', href: 'https://github.com/facebook/react-native', text: 'GitHub'},

website/core/metadata-blog.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @generated
3+
* @providesModule MetadataBlog
4+
*/
5+
module.exports = {
6+
"files": [
7+
{
8+
"path": "2016/03/23/introducing-hot-reloading.html",
9+
"content": "\nThis is a test\n",
10+
"title": "Introducing Hot Reloading",
11+
"author": "Martín Bigio"
12+
}
13+
]
14+
};

website/layout/BlogPageLayout.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule BlogPageLayout
10+
*/
11+
12+
'use strict';
13+
14+
var BlogPost = require('BlogPost');
15+
var BlogSidebar = require('BlogSidebar');
16+
var MetadataBlog = require('MetadataBlog');
17+
var React = require('React');
18+
var Site = require('Site');
19+
20+
var BlogPageLayout = React.createClass({
21+
getPageURL: function(page) {
22+
var url = '/jest/blog/';
23+
if (page > 0) {
24+
url += 'page' + (page + 1) + '/';
25+
}
26+
return url + '#content';
27+
},
28+
29+
render: function() {
30+
var perPage = this.props.metadata.perPage;
31+
var page = this.props.metadata.page;
32+
return (
33+
<Site
34+
section="blog"
35+
title="Blog">
36+
<section className="content wrap documentationContent">
37+
<BlogSidebar />
38+
<div className="inner-content">
39+
{MetadataBlog.files
40+
.slice(page * perPage, (page + 1) * perPage)
41+
.map((post) => {
42+
return <BlogPost post={post} content={post.content} />
43+
})
44+
}
45+
<div className="docs-prevnext">
46+
{page > 0 &&
47+
<a className="docs-prev" href={this.getPageURL(page - 1)}>&larr; Prev</a>}
48+
{MetadataBlog.files.length > (page + 1) * perPage &&
49+
<a className="docs-next" href={this.getPageURL(page + 1)}>Next &rarr;</a>}
50+
</div>
51+
</div>
52+
</section>
53+
</Site>
54+
);
55+
}
56+
});
57+
58+
module.exports = BlogPageLayout;

website/layout/BlogPostLayout.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule BlogPostLayout
10+
*/
11+
12+
'use strict';
13+
14+
var BlogPost = require('BlogPost');
15+
var BlogSidebar = require('BlogSidebar');
16+
var Marked = require('Marked');
17+
var MetadataBlog = require('MetadataBlog');
18+
var React = require('React');
19+
var Site = require('Site');
20+
21+
var BlogPostLayout = React.createClass({
22+
render: function() {
23+
return (
24+
<Site
25+
section="blog"
26+
title={this.props.metadata.title}
27+
description={this.props.children.trim().split('\n')[0]}>
28+
<section className="content wrap documentationContent">
29+
<BlogSidebar title={this.props.metadata.title} />
30+
<div className="inner-content">
31+
<BlogPost post={this.props.metadata} content={this.props.children} />
32+
</div>
33+
</section>
34+
</Site>
35+
);
36+
}
37+
});
38+
39+
module.exports = BlogPostLayout;

0 commit comments

Comments
 (0)