Skip to content

Commit

Permalink
Add "Edit on GitHub" link on normal docs pages
Browse files Browse the repository at this point in the history
Summary:
<img width="938" alt="screen shot 2016-01-20 at 10 38 23 pm" src="https://cloud.githubusercontent.com/assets/197597/12473376/8f0ac970-bfc6-11e5-9e44-0481e9f250f1.png">
Closes facebook#5454

Reviewed By: svcscm

Differential Revision: D2849235

Pulled By: vjeux

fb-gh-sync-id: 0103f3d5249b1dfc03aa77feb9ae3bb7bbe9c746
  • Loading branch information
vjeux authored and facebook-github-bot-7 committed Jan 21, 2016
1 parent a9a7c78 commit 8472209
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion website/layout/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ var DocsLayout = React.createClass({
<DocsSidebar metadata={metadata} />
<div className="inner-content">
<a id="content" />
<h1>{metadata.title}</h1>
<h1>
{metadata.title}
<a
className="edit-github"
href={'https://github.com/facebook/react-native/blob/master/docs/' + metadata.filename}>
Edit on GitHub
</a>
</h1>
<Marked>{content}</Marked>
<div className="docs-prevnext">
{metadata.previous && <a className="docs-prev" href={metadata.previous + '.html#content'}>&larr; Prev</a>}
Expand Down
10 changes: 7 additions & 3 deletions website/server/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function execute() {
files: [],
};

function handleMarkdown(content) {
function handleMarkdown(content, filename) {
var metadata = {};

// Extract markdown metadata header
Expand All @@ -78,6 +78,8 @@ function execute() {
return;
}

metadata.filename = filename;

// Create a dummy .js version that just calls the associated layout
var layout = metadata.layout[0].toUpperCase() + metadata.layout.substr(1) + 'Layout';

Expand Down Expand Up @@ -105,14 +107,16 @@ function execute() {
fs.writeFileSync(targetFile, content);
}

extractDocs().forEach(handleMarkdown);
extractDocs().forEach(function(content) {
handleMarkdown(content, null);
});

var files = glob.sync(MD_DIR + '**/*.*');
files.forEach(function(file) {
var extension = path.extname(file);
if (extension === '.md' || extension === '.markdown') {
var content = fs.readFileSync(file, {encoding: 'utf8'});
handleMarkdown(content);
handleMarkdown(content, path.basename(file));
}

if (extension === '.json') {
Expand Down

0 comments on commit 8472209

Please sign in to comment.