Skip to content

Commit 60dab36

Browse files
committed
Shift home into pages
1 parent 1de3b18 commit 60dab36

File tree

2 files changed

+14
-39
lines changed

2 files changed

+14
-39
lines changed

gatsby-node.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,7 @@ exports.createPages = async ({graphql, boundActionCreators}) => {
6060
allMarkdown.data.allMarkdownRemark.edges.forEach(edge => {
6161
const slug = edge.node.fields.slug;
6262

63-
if (slug === '/index.html') {
64-
createPage({
65-
path: '/',
66-
component: homeTemplate,
67-
context: {
68-
slug,
69-
},
70-
});
71-
} else if (slug === 'docs/error-decoder.html') {
63+
if (slug === 'docs/error-decoder.html') {
7264
// No-op so far as markdown templates go.
7365
// Error codes are managed by a page in src/pages
7466
// (which gets created by Gatsby during a separate phase).

src/templates/home.js renamed to src/pages/index.js

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
'use strict';
88

9-
import ButtonLink from './components/ButtonLink';
9+
import ButtonLink from '../templates/components/ButtonLink';
1010
import Container from 'components/Container';
1111
import Flex from 'components/Flex';
1212
import mountCodeExample from 'utils/mountCodeExample';
@@ -41,14 +41,13 @@ class Home extends Component {
4141
}
4242

4343
render() {
44-
const {data} = this.props;
4544
const title = 'React - A JavaScript library for building user interfaces';
4645

4746
return (
4847
<div css={{width: '100%'}}>
4948
<TitleAndMetaTags
5049
title={title}
51-
ogUrl={createOgUrl(data.markdownRemark.fields.slug)}
50+
ogUrl={createOgUrl('index.html')}
5251
/>
5352
<header
5453
css={{
@@ -142,29 +141,29 @@ class Home extends Component {
142141

143142
<Container>
144143
<div css={[sharedStyles.markdown, markdownStyles]}>
145-
<section class="light home-section">
146-
<div class="marketing-row">
147-
<div class="marketing-col">
144+
<section className="light home-section">
145+
<div className="marketing-row">
146+
<div className="marketing-col">
148147
<h3>Declarative</h3>
149148
<p>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.</p>
150149
<p>Declarative views make your code more predictable and easier to debug.</p>
151150
</div>
152-
<div class="marketing-col">
151+
<div className="marketing-col">
153152
<h3>Component-Based</h3>
154153
<p>Build encapsulated components that manage their own state, then compose them to make complex UIs.</p>
155154
<p>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.</p>
156155
</div>
157-
<div class="marketing-col">
156+
<div className="marketing-col">
158157
<h3>Learn Once, Write Anywhere</h3>
159158
<p>We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code.</p>
160159
<p>React can also render on the server using Node and power mobile apps using <a href="https://facebook.github.io/react-native/">React Native</a>.</p>
161160
</div>
162161
</div>
163162
</section>
164-
<hr class="home-divider" />
165-
<section class="home-section">
163+
<hr className="home-divider" />
164+
<section className="home-section">
166165
<div id="examples">
167-
<div class="example">
166+
<div className="example">
168167
<h3>A Simple Component</h3>
169168
<p>
170169
React components implement a `render()` method that takes input data and
@@ -180,7 +179,7 @@ class Home extends Component {
180179
</p>
181180
<div id="helloExample"></div>
182181
</div>
183-
<div class="example">
182+
<div className="example">
184183
<h3>A Stateful Component</h3>
185184
<p>
186185
In addition to taking input data (accessed via `this.props`), a
@@ -190,7 +189,7 @@ class Home extends Component {
190189
</p>
191190
<div id="timerExample"></div>
192191
</div>
193-
<div class="example">
192+
<div className="example">
194193
<h3>An Application</h3>
195194
<p>
196195
Using `props` and `state`, we can put together a small Todo application.
@@ -201,7 +200,7 @@ class Home extends Component {
201200
</p>
202201
<div id="todoExample"></div>
203202
</div>
204-
<div class="example">
203+
<div className="example">
205204
<h3>A Component Using External Plugins</h3>
206205
<p>
207206
React is flexible and provides hooks that allow you to interface with
@@ -243,7 +242,6 @@ class Home extends Component {
243242
}
244243

245244
Home.propTypes = {
246-
data: PropTypes.object.isRequired,
247245
location: PropTypes.object.isRequired,
248246
};
249247

@@ -285,21 +283,6 @@ const CtaItem = ({children, primary = false}) => (
285283
</div>
286284
);
287285

288-
// eslint-disable-next-line no-undef
289-
export const pageQuery = graphql`
290-
query HomeMarkdown($slug: String!) {
291-
markdownRemark(fields: {slug: {eq: $slug}}) {
292-
html
293-
frontmatter {
294-
title
295-
}
296-
fields {
297-
slug
298-
}
299-
}
300-
}
301-
`;
302-
303286
export default Home;
304287

305288
// TODO This nasty CSS is required because 'docs/index.md' defines hard-coded class names.

0 commit comments

Comments
 (0)