gatsby universal
1.0.0
一个固执己见的Gatsby v2 入门者,具有 React Context、样式化组件、页面转换、 IntersectionObserver
的滚动事件以及对可访问性和 SEO 的关注。专为最先进的营销网站而设计。
您可以在 gatsby-universal.netlify.com 在线访问此入门程序的演示。
IntersectionObserver
,基于组件(带有polyfill) styled-components
v4 size-plugin
来关注你的包大小eslint-plugin-react
)您有建议或反馈吗?打开一个问题!
# Installation with `gatsby-cli`
gatsby new my-site https://github.com/fabe/gatsby-universal
# Installation with `git clone`
git clone [email protected]:fabe/gatsby-universal.git my-site
cd my-site
yarn install
# To develop
yarn develop
# To build
yarn build
# To test SSR (for Lighthouse etc.)
yarn ssr
# To format JS (precommit)
yarn format
# To generate favicons (included in `build`)
yarn build:favicons
在site-config.js
中找到站点范围的配置。
module . exports = {
siteTitle : `Gatsby Universal` ,
siteTitleShort : `GatsbyU` ,
siteDescription : `An opinionated starter for Gatsby.` ,
siteUrl : `https://gu.fabianschultz.com` ,
themeColor : `#000` ,
backgroundColor : `#fff` ,
pathPrefix : null ,
logo : path . resolve ( __dirname , 'src/images/icon.png' ) ,
social : {
twitter : `gatsbyjs` ,
fbAppId : `966242223397117` ,
} ,
} ;
不要忘记更新
static/
内的robots.txt
!
├── gatsby-browser.js # Specify how Gatsby renders pages in the browser
├── gatsby-config.js # Gatsby config, mostly taken from `site-config.js`
├── gatsby-node.js # Modify webpack config
├── gatsby-ssr.js # Specify how Gatsby builds pages
├── site-config.js # Global settings for the whole site, used by multiple scripts
├── content # Content & data, in both json and markdown
├── src
│ ├── components
│ │ ├── head # All meta tags etc.
│ │ ├── io # Intersection Observer component, uses render props
│ │ ├── layout # Layout component
│ │ │ ├── layout.css.js # .css.js for component's `styled-components`
│ │ │ └── layout.js
│ │ └── transition # Page Transition component, used by Gatsby APIs
│ ├── constants # Site-wide constants (breakpoints, colors, etc.)
│ ├── containers # Container components if store is needed
│ ├── helpers
│ │ ├── schemaGenerator.js # Generates JSON-LD schema.org snippets
│ │ └── mediaTemplates.js # Creates media queries for styled-components
│ ├── images # Images needed by the site/theme (not content)
│ ├── pages
│ ├── store # Store and provider of a React.createContext instance
│ └── global.css.js # Global CSS
└── scripts
├── lighthouse.test.js # Tests the site specified inside `site-config.js` with Google Lighthouse (WIP)
└── favicons.js # Generates favicons and manifest using one png only.