Skip to content

Refactor home page #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions content/home/examples/a-component-using-external-plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: A Component Using External Plugins
order: 3
example_name: markdownExample
---

React is flexible and provides hooks that allow you to interface with other libraries and frameworks. This example uses **remarkable**, an external Markdown library, to convert the `<textarea>`'s value in real time.
9 changes: 9 additions & 0 deletions content/home/examples/a-simple-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: A Simple Component
order: 0
example_name: helloExample
---

React components implement a `render()` method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by `render()` via `this.props`.

**JSX is optional and not required to use React.** Try the [Babel REPL](http://babeljs.io/repl#?babili=false&browsers=&build=&builtIns=false&code_lz=MYGwhgzhAEASCmIQHsCy8pgOb2vAHgC7wB2AJjAErxjCEB0AwsgLYAOyJph0A3gFABIAE6ky8YQAoAlHyEj4hAK7CS0ADxkAlgDcAfAiTI-hABZaI9NsORtLJMC3gBfdQHpt-gNxDn_P_zUtIQAIgDyqPSi5BKS6oYo6Jg40A5OALwARCHwOlokmdBuegA00CzISiSEAHLI4tJeQA&debug=false&circleciRepo=&evaluate=false&lineWrap=false&presets=react&prettier=true&targets=&version=6.26.0) to see the raw JavaScript code produced by the JSX compilation step.
7 changes: 7 additions & 0 deletions content/home/examples/a-stateful-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: A Stateful Component
order: 1
example_name: timerExample
---

In addition to taking input data (accessed via `this.props`), a component can maintain internal state data (accessed via `this.state`). When a component's state data changes, the rendered markup will be updated by re-invoking `render()`.
7 changes: 7 additions & 0 deletions content/home/examples/an-application.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: An Application
order: 2
example_name: todoExample
---

Using `props` and `state`, we can put together a small Todo application. This example uses `state` to track the current list of items as well as the text that the user has entered. Although event handlers appear to be rendered inline, they will be collected and implemented using event delegation.
8 changes: 8 additions & 0 deletions content/home/marketing/component-based.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Component-Based
order: 1
---

Build encapsulated components that manage their own state, then compose them to make complex UIs.

Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM.
8 changes: 8 additions & 0 deletions content/home/marketing/declarative.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Declarative
order: 0
---

React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes.

Declarative views make your code more predictable and easier to debug.
8 changes: 8 additions & 0 deletions content/home/marketing/learn-once-write-anywhere.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Learn Once, Write Anywhere
order: 2
---

We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code.

React can also render on the server using Node and power mobile apps using [React Native](https://facebook.github.io/react-native/).
76 changes: 0 additions & 76 deletions content/index.md

This file was deleted.

18 changes: 8 additions & 10 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
const communityTemplate = resolve('./src/templates/community.js');
const docsTemplate = resolve('./src/templates/docs.js');
const tutorialTemplate = resolve('./src/templates/tutorial.js');
const homeTemplate = resolve('./src/templates/home.js');

// Redirect /index.html to root.
createRedirect({
fromPath: '/index.html',
redirectInBrowser: true,
toPath: '/',
});

const allMarkdown = await graphql(
`
Expand Down Expand Up @@ -60,15 +66,7 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
allMarkdown.data.allMarkdownRemark.edges.forEach(edge => {
const slug = edge.node.fields.slug;

if (slug === '/index.html') {
Copy link
Contributor Author

@yangshun yangshun Oct 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer need to programatically create home page because it is now within the pages directory.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dig it.

createPage({
path: '/',
component: homeTemplate,
context: {
slug,
},
});
} else if (slug === 'docs/error-decoder.html') {
if (slug === 'docs/error-decoder.html') {
// No-op so far as markdown templates go.
// Error codes are managed by a page in src/pages
// (which gets created by Gatsby during a separate phase).
Expand Down
Loading