์ฐ์ , GATSBY์ ๋ชจ๋ ๊ธฐ์ฌ์ ๋๋ถ์ ๋๋ ๊ทธ๊ฒ์ ์ฌ๋ํฉ๋๋ค! ๋ด ์ง๋ฌธ์ ๋งค์ฐ ๊ฐ๋จํ์ง๋ง ๋ต๋ณ์ด ํฌํจ๋ ๊ฒ์๋ฌผ์ ์ฐพ์ ์ ์์ต๋๋ค.
Typography.js๋ฅผ ์ฌ์ฉํ์ง ์๋ ๊ฒฝ์ฐ gatsby-plugin-styled-components์ ๋ํ ์ ์ญ ์คํ์ผ์ ์ด๋ป๊ฒ ์ฃผ์
ํ ์ ์์ต๋๊น?
์๋ฅผ ๋ค์ด:
๋ค์ ์ฝ๋๋ฅผ ์ด๋์ ์ฝ์
ํฉ๋๊น?
injectGlobal`
* { box-sizing: border-box; }
body { margin: 0; color: #374047}
`
๋ฏธ๋ฆฌ ๊ฐ์ฌ๋๋ฆฝ๋๋ค!
๋ด๊ฐ ์คํดํ๊ณ ์์ด (์ด ์ง์ ์คํ์ผ์ ๊ตฌ์ฑ ์์์ ๋ค๋ฅด๊ฒ ์ผ์ํด์ผ)ํ์ง ์๋ ํ, HN ์ฌ์ดํธ ์๋ฅผ ๋ค์ด ์ด ๋ฌ์ฑ ํ ์์๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค https://github.com/gatsbyjs/gatsby/blob/5a0aac34bc4a509e871f524d8705cb9e0a501ce1/examples/hn/ src/๋ ์ด์์/default.js#L4
ํธ์ง: injectGlobal
๊ฐ ์คํ์ผ์ด ์ง์ ๋ ๊ตฌ์ฑ ์์ ๋ฐฉ๋ฒ์ด๋ผ๋ ๊ฒ์ ๊นจ๋ซ์ง ๋ชปํ์ง๋ง @ https://www.styled-components.com/docs/api์์ ๋ณผ ์
@dustinhorton ๊ฐ์ฌํฉ๋๋ค.
index.js ํ์ผ๋ก ๋ ์ด์์ ํด๋๋ฅผ ๋ง๋ค์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ค์ ์ ์ญ ์คํ์ผ์ ์ฃผ์
ํ๊ณ ๋งค๋ ฅ์ฒ๋ผ ์๋ํ์ต๋๋ค :-)
import React from "react"
import { injectGlobal } from 'styled-components'
injectGlobal`
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: inherit; }
html {
font-size: 62.5%; }
body {
box-sizing: border-box; }
body {
font-family: "Lato", sans-serif;
font-weight: 400;
line-height: 1.7;
color: #374047; }
`
export default ({children}) =>
<div>
{children()}
</div>
@ferMartz ์ด ๋ฌธ์ ๋ฅผ ๋ซ์ ์ ์์ต๋๊น? :)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@dustinhorton ๊ฐ์ฌํฉ๋๋ค.
index.js ํ์ผ๋ก ๋ ์ด์์ ํด๋๋ฅผ ๋ง๋ค์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ค์ ์ ์ญ ์คํ์ผ์ ์ฃผ์ ํ๊ณ ๋งค๋ ฅ์ฒ๋ผ ์๋ํ์ต๋๋ค :-)