/* step 1_install gatsby cli */
npm install -g gatsby-cli
/* step 2_Create gatsby project name on terminal */
gatsby new projectName
//! if you install gatsby without cli , use below code
npx gatsby-cli new projectName
/* step 3_Install typescript */
yarn add typescript --dev
yarn add gatsby-plugin-typescript
//! if you apply typescript on your project, please follow below steps
/* step 4_Create tsconfig.json */
yarn tsc --init
/* step 5_Modify gatsby-config.js */
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`,
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
author: `@gatsbyjs`,
siteUrl: `https://gatsbystarterdefaultsource.gatsbyjs.io/`,
},
plugins: [
`gatsby-plugin-typescript`, // -> that has been added!
`gatsby-plugin-react-helmet`,
`gatsby-plugin-image`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `contents`,
path: `${__dirname}/contents`,
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/gatsby-icon.png`,
},
},
`gatsby-plugin-gatsby-cloud`,
],
}
/* step 6_Modify gatsby-node.js */
const path = require('path');
// Setup Import Alias
exports.onCreateWebpackConfig = ({ getConfig, actions }) => {
const output = getConfig().output || {};
actions.setWebpackConfig({
output,
resolve: {
alias: {
components: path.resolve(__dirname, 'src/components'),
utils: path.resolve(__dirname, 'src/utils'),
hooks: path.resolve(__dirname, 'src/hooks'),
//! if you wan to import file like
// import Test from "@src/components/Test";
'@src': path.resolve(__dirname, 'src'),
},
},
});
};
/* step 7_Install both tailwind and postcss and it makes tailwind.config.js & postcss.config.js automatically */
npm install -D tailwindcss postcss autoprefixer gatsby-plugin-postcss
npx tailwindcss init -p
/* step 8_Apply postcss on gatsby-config */
module.exports = {
plugins: [
'gatsby-plugin-postcss',
// ...
],
}
/* step 9_Apply routes on tailwind.config.js */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
/* step 10_Create global.css and put below code in */
route : './src/styles/global.css'
@tailwind base;
@tailwind components;
@tailwind utilities;
/* step 11_Apply global css which has put tailwind codes in on gatsby-browser.js */
import './src/styles/global.css'
λΈλ‘κ·Έ ν¬μ€νΈ κ΄λ ¨ νμΌλ€μ μ μ₯νκΈ° μν λλ ν 리.
νμ΄μ§μ μν μ νλ μ»΄ν¬λνΈλ₯Ό μ μ₯νκΈ° μν λλ ν 리. κΈ°λ³Έμ μΌλ‘ λΈλΌμ°μ μμ pages λλ ν 리μ μλ νμΌμ μ΄λ¦μ ν΅ν΄ νμ΄μ§μ μ κ·Όν μ μκΈ° λλ¬Έμ νμ΄μ§μ μν μ΄ μλ μ»΄ν¬λνΈλ€μ ν΄λΉ λλ ν 리μ μ μ₯νμ§ μλλ€. λν, νμ΄μ§μ ν νλ¦Ώ νμΌμμλ§ Query μ μκ° κ°λ₯νλ€. μΌλ°μ μΈ μ»΄ν¬λνΈμμλ λ³μλ‘μ μ μκ° λΆκ°λ₯νκ³ , StaticQueryλΌλ κΈ°λ₯μ ν΅ν΄ μ μκ°λ₯.
Custom Hooksμ μ μ₯νκΈ° μν λλ ν 리.
κ²μκΈ νμ΄μ§μ κ°μ΄ νμ΄μ§μ μν μ νλ©΄μ κ°μ νμμ μ¬λ¬ μ½ν μΈ λ₯Ό 보μ¬μ£Όλ μ»΄ν¬λνΈλ₯Ό μ μ₯νκΈ° μν λλ ν 리.
Gatsbyμμ μ 곡νλ APIλ₯Ό ν΅ν΄ μ΄ λλ ν 리μ μ μ₯λ ν νλ¦Ώ μ»΄ν¬λνΈλ‘ μ¬λ¬ νμ΄μ§λ₯Ό λ§λ λ€.
pages λλ ν 리μλ λ€λ₯΄κ² νμΌλͺ μΌλ‘ νμ΄μ§μ μ κ·Όμ΄ λΆκ°νλ€.