-
using Gatsby starters
gatsby new project-dir-name (<url-of-starter-pack-repo>), ifurl-of-starter-pack-repois not given it uses default starter -
doc has details on modifying a starter
-
here we'll familiarize with code structure in context of hello-world started pack
-
src/pages/index.jsis the home index page asJSX, Gatsby uses hot reloading during development process
-
in Gatsby these are React Components; its like initially if you were creating multiple classes for a visual construct, now you create a component
-
any React component defined in
src/pages/*.jsturns into Page component, like hello-world/src/pages/a-page.js turns into /a-page -
can use sub-components within Pages by adding them to
src/components/*.js, like hello-world/src/components/subheader.js can be used as<SubHeader/>in all pages on relative import
check how innerHTML is passed and decorated
- can also pass on properties to the components, like
headerTextin hello-world/src/components/header.js
check how basic properties are passed
-
layout componentsare for sections of site to be shared across multiple pages, like a shared header & footer with a sidebar menu -
use following for internal routing in Gatsby, with
import { Link } from "gatsby"using<Link to="/page">some text</Link>
- it doesn't depend on any Databases, build command produces a static site-bundle to be deployed
gatsby build
it generates deploy-able site-bundle in
<project-dr>/publicdirectory
- can try surge to publish for public sites