leobang17 / gatsby-theme-simplex Goto Github PK
View Code? Open in Web Editor NEW๐ Gatsby theme for bootstrapping a simple blog
License: BSD Zero Clause License
๐ Gatsby theme for bootstrapping a simple blog
License: BSD Zero Clause License
ํ์ฌ nav์ ์์๋ค๊ณผ layout์ ๋ ๋ถ๋ถ์ ์ ๋ ฌ์ด ์ ๋ง์ง ์๋๋ค.
ํนํ layout์ main ๋ถ๋ถ์ ๊ฒฝ์ฐ ์ข์ฐ margin์ด ์กํ์์ง ์์ ์ฐฝ์ด ์ข์์ง ๊ฒฝ์ฐ ๋ ๋ถ๋ถ์ ๋ฑ ๋ถ์ด๋ฒ๋ฆผ.
Footer ๋ฐ์ํ ๊ฐ์ . ํ์ฌ๋ ๋ชจ๋ฐ์ผ ํ๋ฉด๋๋น์์ overflow๋ก ๋ฐ์ผ๋ก ํ ์คํธ๊ฐ ๋ฐ๋ฆฐ๋ค.
Nav ๋ฐ ๊ฐ์ ํฉ๋๋ค.
ํธ์คํ ํ๊ณ ์๋ ๋๋ฉ์ธ ๋ด ์๋ชป๋ route๋ฅผ hit ํ์ ๋ ํ์ํ 404 ํ์ด์ง๋ฅผ ๋ง๋ค์ด๋ณด์์
ERROR #85923 GRAPHQL.VALIDATION
There was an error in your GraphQL query:
Cannot query field "major" on type "MdxFieldsCategory".
If you don't expect "major" to exist on the type "MdxFieldsCategory" it is most likely a typo. However, if you expect "major" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node/gatsby-config, please try a restart of your development server.
- You want to optionally use your field "major" and right now it is not used anywhere.
It is recommended to explicitly type your GraphQL schema if you want to use optional fields.
File: src/templates/ArticlePage.tsx:33:11
See our docs page for more info on this error: https://gatsby.dev/creating-type-definitions
/documents
path์ ์นดํ
๊ณ ๋ฆฌ๊ฐ ํ๋๋ ์์ ๋ ๋ฐ์ํ๋ ์๋ฌ.
onCreateNode API ์ด์ฉ์ ๊ธฐ์กด MDX ๋
ธ๋์ ์ถ๊ฐํ major
ํน์ minor
ํ๋กํผํฐ๊ฐ ํ๋๋ ์์ด ์๊ธฐ๋ ์๋ฌ ๊ฐ์.
๋๊ธ ํจ ๋ฌ์๋ณด์ ์๋
Article Page์ ๊ฐ์ ํฉ๋๋ค.
๊ณต์๋ฌธ์๋ฅผ ์ฝ๊ณ Gatsby์ Head API๋ฅผ ์ด์ฉํด ๊ฐ ๋ฌธ์์ head tag๋ฅผ ์ฑ์๋ณด์์~
Gatsby ๊ณต์๋ฌธ์๋ฅผ ์ฝ๊ณ SEO๋ฅผ ์ํํด๋ณด์์.
์๋ category tree๋ฅผ ์์ฑํ๋ ๋
ธ๋์ ๋ํด์๋ง ๊ฐ๋จํ ๋ณ๊ฒฝํ๋ ค๊ณ ํ๋๋ฐ... ๊ทธ๊ฒ ๊ทธ๋ ๊ฒ ๊ฐ๋จํ์ง ์์๋ค.
category ๊ด๋ จํ ๊ตฌ์กฐ๋ฅผ ๋ฏ์ด๊ณ ์น๊ณ ์ด๋ฅผ category tree, article page, category page์ ์ฌ๋ฐ๋ฅด๊ฒ ๋ฟ๋ ค์ฃผ๋๋ก ํ๋ค.
๊ฒธํ์ฌ dataLayer path๋ฅผ ์์ฑํ๊ณ ๋ฐ์ดํฐ๋ ์ด์ด์ ์ ๊ทผํ๋ api point๋ฅผ ์์ฑํ๋ค.
๊ธฐ์กด์ ์ฐ๊ฐ๋ ํจ์๋ค์ ๋ฆฌํฉํ ๋งํ์ฌ ํด๋์คํ ํ๋๊ฒ ๋ชฉ์ ์ธ๋ฐ ... gatsby๊ฐ graphql ์ฟผ๋ฆฌ๋ฅผ ์ด์ฉํ๋ page ์ static์ผ๋ก ๋๋์ด์ ธ์๊ณ , ๋ ์ด๋ฅผ node api ์์์ ์ด์ฉํ ๊ฒฝ์ฐ ํด๋น api๊ฐ ์ ๊ณตํ๋ parameter์ธ graphql ๋ฉ์๋๋ฅผ ์ด์ฉํด์ผํ๋์ง๋ผ ๊ตณ์ด ๋ชจ๋ ์ผ์ด์ค์ ๊ฒฝ์ฐ๋ฅผ ๋ค๋ฃจ๋๊ฒ ํ์ํ ์ง๋ ์ ๋ชจ๋ฅด๊ฒ ๋ค.
API -> Service -> QueryService -> Query
์์ผ๋ก ์์กดfontsource๋ฅผ ์ด์ฉํด global ๋ก font ์ ์ฉ
Layout component ์์ฑ
@@@
Nav
RightStack Content LeftStack
Footer
@@@
Layout component๋ฅผ ์ฌ์ฌ์ฉํ ์ ์๋๋ก ๊ตฌํ..
์์ Layout์ ๊ธฐ๋ณธ์ผ๋ก Page ๋จ์๋ก๋ ์ด๋ฅผ ์์ธํ๊ฒ ๊ตฌํํ Layout component๋ฅผ ๋ง๋ค ์์ .
์ง๊ธ์
slug ์ ๋ต๋ฅผ ๋ณด๋ค ๊ฐ์ ํฉ๋๋ค.
๋ธ๋ก๊ทธ์ ๊ฒ์ ๊ธฐ๋ฅ์ ์ถ๊ฐํ๊ณ ์ถ๋ค์์น
๊ธ์ ๊ฐ์ฅ ๋ง์ง๋ง์ ์์ ํ ์ผ์๋ฅผ ํ์ธํ ์ ์๋๋ก ํฉ๋๋ค.
Bio ๊ตฌํ
article page์ ๋ง์ง๋ง ๋ถ๋ถ์ ๋ค๋ฅธ ๊ธ๋ก๋ ํ์ํ ์ ์๋๋ก ํ๋ ค๊ณ ํฉ๋๋ค.
related post ๋ recent post, ํน์ ์ด์ ๊ธ - ๋ค์๊ธ ์ค ๋ญ๋ผ๋ ์ผ๋จ ๋ณด์ฌ์ฃผ๋ ค๊ณ ํฉ๋๋ค.
readme์ ๋ฐ๋ฅด๋ฉด gatsby-transformer-remark
๋ฟ ์๋๋ผ gatsby-plugin-mdx
์ญ์ ํธํํ๋ค๊ณ ๋์์๋๋ฐ ์ผ๋จ ์ ์ฉ์ด ์๋จ.
issue ๋จ๊ธฐ๊ณ ๋ค์ ์ ์ฉํด๋ณด๊ธฐ.
๊ธฐ์กด์๋ Gatsby ํ๊ฒฝ์ ๊ตฌ์ฑํ๋ ํ์ผ๋ค์ CommonJS์ ๊ธฐ๋ฐ์ผ๋ก ์์ฑ๋์ด์ผ ํ์๋ค. (๊ณ ํ๋ค)
์ฌ์ค ๊ธฐ์กด์๋ gatsby-config
๋ gatsby-node
๋ฅผ .ts ํ์ฅ์๋ก ์์ฑํ๊ณ ๋ด ์์ค์ฝ๋์ ํจ์๋ ๋ณ์๋ค์ ES6์ ๋ฌธ๋ฒ์ ๋ง๊ฒ import ํด์ค๊ธด ํ์์ง๋ง. ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ฐ์ ธ์์ผํ ๊ฒฝ์ฐ์๋ cjs์ require()
๋ฅผ ์ด์ฉํ์๋ค.
๋ฌธ์ ๋ mdx์ ๊ด๋ จ๋ ์ต์
๋ค์ ์๋ํํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ์ด์ฉํด ๋ฐ์ํด์ผํ ๋ ์ธ๋ฐ... remark๋ rehype ๊ด๋ จ ๋๋ถ๋ถ ๊ตฌ๋ฒ์ ์ ์ ์ธํ๊ณ ๋ ESM ๋ชจ๋ ํ๊ฒฝ์์๋ง ์คํ๋๊ธฐ ๋๋ฌธ์ gatsby-config์์ ์ด ์๋ํํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ์ค์ ํ๋ ค๋ฉด ์ ์ฝ์ฌํญ๋ค์ด ์์๋ค.
์ค์ ๋ก ์์ง๋ ๊ณต์ ํ์ด์ง์ docs์์๋ ๋ค์ ์ ์ฝ์ฌํญ์ ๋ช
์ํ๊ณ ์๋ค.
https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/?=mdx#mdxoptions
๋๋ถ๋ถ์ remark๋ rehype ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ only ESM ์ด๋ผ๋ ๋ฑ์ง๋ฅผ ๋ฌ๊ณ ๋์จ๋ค. ๋ฐ๋ผ์ ์ผ์ผ์ด ๋ฆด๋ฆฌ์ฆ ๋
ธํธ๋ฅผ ํ์ธํ๋ฉฐ ESM์ด ์ ์ฉ๋์ง ์์ ๋ฒ์ ์ ์ค์นํ๋ ์ผ์ x
๋๋ฒ์งธ wrapper ํจ์๋ ์์ธ์ง ์ฌ๋ฐ๋ฅด๊ฒ ๋์ํ์ง ์์๋ค.
gatsby์ ๋ฆด๋ฆฌ์ฆ ๋
ธํธ๋ฅผ ๋ค์ ธ๋ณด๋ v5.3์์ gatsby-config์ gatsby-node ์ญ์ esm์ ๋ฐ์ํ๋๋ก ๋ณ๊ฒฝํ๋ค๊ณ ํ๋ค!
https://www.gatsbyjs.com/docs/reference/release-notes/v5.3/
์ ๊ณต์๋ฌธ์์ ์ ์ ์ด๋์๊ฑด์ง;; ๋ค์ ๋ณด๋ ๋ ํฌ์งํ ๋ฆฌ์ ํจํค์ง ์ ์ต์ readme์๋ ๋ฐ์์ด ๋์ด์์๋ค.
https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-mdx#mdxoptions
์ต๊ทผ์ ๋ค์ ๋ธ๋ก๊ทธ ์์ ์ ๋ค์ ์์ํ๋ฉด์ gatsby ๋ฒ์ ์ ์
๊ทธ๋ ์ด๋ ํ์๋๋ฐ ์ด ๋ ๋ฐ์๋์ด์ ์๋ ๋ฌธ์์ ์ ํ์๋ wrapper ํจ์๊ฐ ์๋ํ์ง ์์ ๋ฏ...?
์๋ฌดํผ esm์ ๋ฐ์์ ํ๊ธดํ๋๋ฐ, .mjs
ํ์ฅ์์ ํ์ผ๋ง ๊ฐ๋ฅํ๊ณ ์์ง ํ์
์คํฌ๋ฆฝํธ ํธํ์ ์๋๋ค๊ณ ํ๋ค.
gatsbyjs/gatsby#37069
mjs์ ๊ดํ umbrella discussion
๋ฒ ํ ๋ฒ์ ๋ฐฐํฌ์ ์์ ์์ํ ์์ ๋ค์ ์ํํฉ๋๋ค.
MDX ์คํ์ผ๋ง์ด ๋์ด์์ง ์์ ์ํ์
๋๋ค.
MDXProvider๋ฅผ ์ด์ฉํด ์ ์ฒด์ ์ธ ์คํ์ผ์ ์ ์ฉํ๊ณ , ๊ธฐ์กด ๋ฏธํกํ ์ ์ ๊ฐ์ ํฉ๋๋ค.
๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ ์ค์ ๋ฐ ๋์ ํ์ด์ง ์์ฑ
category๊ด๋ จํ string์ directory string์ผ๋ก ๋ฐ๊ฟจ๋ค ๋ญํ๋ค slug๋ก ๋ง๋ค์๋ค ๋ฐฐ์ด๋ก ๋ง๋ค์๋ค ํ๋ ์์
๋ค์ด ์ฐ๊ฐ๋์ด์์. ์ฃผ๋ก util function์
ํ๋์ ํด๋์ค๋ก ๋ง๋ค์ด ์์ฑ ๋ฐ ๊ด๋ฆฌํ๋๋ก CategoryString ๊ฐ์ฒด๋ฅผ ์ ์ํฉ๋๋ค.
์กฐ๊ธ ๋ฆ์ ๊ฐ์ด ์์ง๋ง ํ๋ก์ ํธ์ ์ฌ์ฉ๋ vscode snippet์ ์ ์ํจ.
Nav๋ฐ ๊ฐ๋ฐ
mdx ํ๊ธฐํฉ๋๋ค... mdx๋ฅผ ์ด์ฉํ๋ ๋์ Gatsby๊ฐ ์ ๊ณต์ docs์ ๋ฐ์ด์ฃผ๋์ง ๋ชจ๋ฅด๊ฒ ์๋งํผ ์ง์ฆ๋๋ ์ผ๋ค๋ง ์์๋ค. gfm์ผ๋ก ์์ฑํ ํ
์ด๋ธ์ ์์ ํ๋ฉด์์๋ ์์ผ๋ก ์ญ ๋ฐ๋ฆฌ์ง ์๋.. theme์ ๋ ์ ์ฉํ๋๊ฒ ๋ญ์ด๋ฆฌ ํ๋ ์ง.
๊น์ด ์ดํดํ๊ณ ์ปค์คํฐ๋ง์ด์ง์ ์ํ๋ค๋ฉด ๋ชจ๋ฅด๊ฒ ์ง๋ง ๋์ฒ๋ผ ๊ทธ๋ฅ ๊ฐ๋จํ๊ฒ ๋ธ๋ก๊ทธ ๋๋ฑ ๋ง๋ค์ด์ ์ด์ฉํ๊ณ ์ถ์ ์ ์ ์๊ฒ๋ ๋ง์ง ์๋ ํ๋ฌ๊ทธ์ธ์ด์๋ค.
๊ทธ๋๋ง ์ฅ์ ์ rehype ์๋ํํฐ ํ๋ฌ๊ทธ์ธ๋ค์ ์ต์
์ผ๋ก ๋ฐ์๋ค์ด๋ ๊ฑฐ ๊ฐ๊ธดํ๋ฐ .. ๊ณต์๋ฌธ์์์๋ ๋ชจ๋๊ฐ ํธํ์ด ์๋๋ ๋ฌธ์ ๋ฅผ ์์๋ฐฉํธ์ผ๋ก ํด๊ฒฐํ๋ ์์ ๋ฅผ ๋ณด์ฌ์ฃผ๊ณ ์๊ณ , 5.3 ๋ฒ์ ์ดํ๋ก๋ esm์ ์ง์ํ์ง๋ง ๊ทธ๋ง์ ๋ rehype ํ๋ฌ๊ทธ์ธ๋ค ์ ์ฉํด๋ณด๋ฉด ๋๋๊ฑด์ง ์๋๋๊ฑด์ง ๋ชจ๋ฅด๊ฒ ๋ ๋๋ค์ด ๋ง์๋ค.
๊ทธ๋ฆฌ๊ณ ์ ์ด์ remark, rehype ์๋ค๋ ๋ฌธ์๋ฅผ ์์ด๋ ๊ฒ ๋์ถฉ๋ง๋๋ ๊ฑธ๊น? ๋ญ ๊ธฐ๋ํ๋ฉด ๋๋ ํ๋ฌ๊ทธ์ธ๋ค์ธ์ง ์ ์๊ฐ ์์ผ๋ ์ค์นํ๊ณ ์ถ์ง๋ ์์๋ค.
๋๋ ๋งํฌ๋ค์ด ํ์ฑํด์ html๋ก ๋ฐ๊พธ๋ ๊ทธ ์์ ์๋ฆฌ ๊ฐ์๊ฑด ๊ทธ๋ค์ง ์๊ณ ์ถ์ง ์๋ค๊ณ ..
๊ทธ๋๋ trasnformer-remark๋ ์ ์ด์ gatsby์ ํธํ๋๊ฒ ์ด๋ฆ์ ๋ฌ๊ณ ๋์จ ๋
์๋ค์ด ๋ง์ผ๋ ๊ด์ฐฎ์ง ์์๊น? ํ๋ ๊ธฐ๋์ ์ด๋ฏผ์ ์๋ํด๋ณด๋ ค๊ณ ํ๋ค.
transformer-remark๊ฐ ๋ ์ค๋๋ ํ๋ฌ๊ทธ์ธ์ด๊ณ , ํ์ฌ๋ ๊ณต์๋ฌธ์์์๋ mdx -> transformer-remark๋ก์ ๋ง์ด๊ทธ๋ ์ด์
์ ์ค๋ช
๋ฐ ๊ถ์ฅํ๊ณ ์์ผ๋ ๋๋ ๋ค์ด๊ทธ๋ ์ด๋๋ฅผ ์๋ํ๋ ๊ฑฐ๊ฒ ์ง.
๊ทธ์น๋ง mdx๋ ๋์ ํ ๋ชป์จ๋จน๊ฒ ๋ค. ์ปค๋ฎค๋ํฐ๊ฐ ํ๋ถ?ํ ๋ ๊ฑฐ์๋ก ๊ทํํด์ผ๊ฒ ๋ค..
๋งํฌ๋ค์ด ๋ฒ ์ด์ค ๋ธ๋ก๊ทธ ํ๋ก์ ํธ์ธ๋งํผ ๋๊ณต์ฌ๊ฐ ๋ ์์ ์ธ๋ฐ ์ ํด๋ผ ์ ์์์ง ์กฐ๊ธ ๋ง๋งํ๋ค.
๋ฐ์ํ์ ๋ง๊ฒ Layout ์์
[Feat] Footer ์์ฑ ๋ฐ page์ min-height ์กฐ์ (#20)
CategoryPage๋ฅผ ๊ฐ์ ํฉ๋๋ค.
์ง์ง ์ด ์ด์๊ฐ ์์ ๋ถํฐ ๊ณ์๋์ด์ ๋๋ฌด๋๋ฌด ์ง์ฆ๋๋๋ฐ.. ์์ธ์ง ์ด์ ๋ ๋ชจ๋ฅด๊ฒ ์ด์ ๊ทธ๋ฅ ๋ฅ ํผํ๊ธฐ ์ฉ์ผ๋ก ์จ๋์
gatsby docs, issues, discussions ๋ค ๋ค์ ธ๋ดค๋๋ฐ ๋๊ฐ์ ์ผ์ด์ค๋ ์๋ ๊ฒ ๊ฐ๋ค.
onCreateNode ๋ผ์ดํ์ฌ์ดํด์์ ์๊ธด ๋ฌธ์ ๋ฐ ์ด ์๋ฌ๋ฉ์์ง๊ฐ mdx node ๋ง๋ค ์๊ธฐ๋ ๊ฒ ๊ฐ๋ค
์ด๋ ๋๋ฌธ์ ๊ทธ ๋ค์ gatsby ๋น๋ ์ฌ์ดํด ๋ค ํฐ์ง๊ณ ๋์ค์ ์นํฉ ๋น๋๋ ํฐ์ง๊ณ ๋ด ์๋ ํกํก ํฐ์ง๋ค
๋ฌธ์ ์ด์ ๋ ์ด์ด์๋๊ฒ ํน์ ํ์ผ์์ path alias๋ฅผ ์ด์ฉํด import ํ๋ฉด ํฐ์ง๋ค. ๊ทธ๋ฅ relative path๋ก importํ๋ฉด ์ํฐ์ง ใ
ใ
์์ผ๊น?
์ฌ์ง์ด ๊ทธ ํน์ ํ์ผ๋ค์ด node API๋ ๊ด๋ จ ์๋ ๊ฒ๋ ์๋. query๋๋ ๊ด๋ จ ์๋ ๊ฒ๋ ์๋๋ค. CategoryTree๋ gatsby์ ์ ํ ๊ด๋ จ ์๋ ๋ฐ๋๋ผ TS ๊ฐ์ฒด์ธ๋ฐ ํฐ์ง๋๊ฑฐ ๋ณด๋ฉด ๋ฌด์จ ๊ธฐ์ค์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ๋ค.
์ด์ ๊ฐ ์ด์ด์์ด์ ํธ๋ฌ๋ธ ์ํ
ํ๊ธฐ๋ ์ซ์ ์ด์๋ค.. ๋์ค์ ๋ธ๋ก๊ทธ ๊ฐ๋ฌด๋ฆฌ ๋ ์ฏค์ ํด๊ฒฐํด์ผ์ง
์์ ์๋ typescript๊ฐ ํ์
ํ ํ๋ ์ฌ๋ฏธ๋ ์๊ณ ๋น๊ต์ ์์ ๋กญ๋ค๊ณ ์๊ฐํด์ ์ข์ํํ๋๋ฐ ์ฐ๋ฉด ์ธ์๋ก Java๊ฐ ๋ต๋ตํ๊ธฐ๋ ํด๋ ์ข์ ์ธ์ด๋ผ๋ ๊ฑธ ๋๋๋ค.
Java + IntelliJ ์กฐํฉ์ ์ ์ด๋ค. ์ฝํ๋ฆฐ ๋ฐฐ์๋ณผ๊น
/src/dataLayer/services/CategoryService.ts
/src/datastructures/category/CategoryTree.ts
/src/hooks/createCategoryPages.ts
/src/hooks/onMdxAppendFields.ts
/src/utils/nodeApi/parseCategory.ts
< ์ง์ง ์๋ ์ ํฐ์ง๋๊ฑฐ์ผCategory ์ฌ์ด๋๋ฐ๋ฅผ ๊ฐ์ ํฉ๋๋ค.
node ์์ฑ์ ์นดํ
๊ณ ๋ฆฌ ์์ฑ ๋ฐ ์นดํ
๊ณ ๋ฆฌ๋ฐ ์ข์ธก ์ถ๋ ฅ
์นดํ
๊ณ ๋ฆฌ ํ์ด์ง ์์ฑ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.