From 09d4fbfe2733893c60e24d997c9a2a79719bd4ce Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 18 Oct 2017 14:03:43 +0300 Subject: [PATCH] Add documentation about adding static pages --- docs/static-pages.md | 229 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 222 insertions(+), 7 deletions(-) diff --git a/docs/static-pages.md b/docs/static-pages.md index 9e62341f..4d9d8996 100644 --- a/docs/static-pages.md +++ b/docs/static-pages.md @@ -1,15 +1,230 @@ # Static pages -TODO +If you want to create simple pages that just show static content without need for data fetches, +you can create a static page. -## Creating the component +Steps to do a static page: +1) [Create a new folder under `src/containers/`](#1-creating-a-new-folder) +2) [Create a new JavaScript file with the same name.](#2-creating-javascript-file) +3) [Create a new CSS file with the same name.](#3-creating-css-file) +4) [Write the content to JavaScript file (i.e. AboutPage.js in our example).](#4-creating-the-component) +5) [Write the style rules to CSS file (i.e. AboutPage.css in our example).](#5-creating-the-css-file) +6) [Add the newly created page component to `src/containers/index.js`](#6-adding-the-component-to-the-component-directory) +7) [Add the newly created page to `src/routeConfiguration.js`](#7-adding-a-route-to-the-page) -TODO +## 1. Creating a new folder -## Adding the component to the index of components +Create a new folder under `src/containers/` with the name of your static page. E.g. "about" page should be named as `AboutPage` -TODO +## 2. Creating JavaScript file -## Adding a route for the component +Create a new JavaScript file with the same name. (Path should look like `src/containers/AboutPage/AboutPage.js`.) -TODO +## 3. Creating CSS file + +Create a new CSS file with the same name. (Path should look like `src/containers/AboutPage/AboutPage.css`.) + +## 4. Creating the component + +Template for single column static page (AboutPage.js): +(We'll go through this line-by-line below.) + +```jsx +import React from 'react'; +import { StaticPage, TopbarContainer } from '../../containers'; +import { + LayoutSingleColumn, + LayoutWrapperTopbar, + LayoutWrapperMain, + LayoutWrapperFooter, + Footer, + NamedLink, + ExternalLink +} from '../../components'; + +import css from './AboutPage.css'; +import image from './path/to/image.png'; + +const AboutPage = () => { + return ( + + + + + + +

Some content

+ My first ice cream. +
+ Go to home page or + Go to Google +
+
+ +