ã¯ããã¾ãã¦ãæ ªå¼ä¼ç¤¾ã«ããã·ã®ã¨ã³ã¸ã㢠@tomiã§ãã
ã«ããã·ã¯ã2020å¹´10æã«ãµã¼ãã¹ãµã¤ãããã«ãªãã¥ã¼ã¢ã«ãã¾ããã
ä»åã®ãµã¤ããªãã¥ã¼ã¢ã«ã§ã¯ãã©ã®ãããªæ§æã§ä½ã£ãã®ããã¾ãæè¡é¸å®ã§èæ ®ããç¹ããä¼ããã¾ãã
Jamstackãªéçãµã¤ãæ§æ
Gatsby.jsã¨Wordpressã使ãJAMstackæ§æã§ä½æãã¾ããã
æçµçã«ä»¥ä¸ã®ç»åã®ãããªæ§æã«ãªãã¾ããã
å©ç¨ããæè¡ã並ã¹ãã¨ã
å°å ¥äºä¾ãã»ããã¼æ å ±ãªã©ãåçãªæ å ±ã¯è¨äºã¨ãã¦Wordpressã«ç»é²ããGatsby.jså´ã§è¨äºãGraphQLçµç±ã§åå¾ãã¦è¡¨ç¤ºãã¦ãã¾ãã
éçãªãã¡ã¤ã«ã®ãã«ãã»ãããã¤ã»ãã¹ãã£ã³ã°ã¯ãã¹ã¦Netlifyã«ãã¾ãããã¦ãããWordpressã§è¨äºãæ´æ°ããã¨ãã¨ã³ã¼ããä¿®æ£ããã¨ãã¯ãWebhookã§èªåãã«ãããããã«è¨å®ãã¦ãã¾ãã
ãªããã®æ§æã»æè¡ã«ããã®ã
â ãã«ãªãã¥ã¼ã¢ã«ãããªãJAMstack
ããããããªãã¥ã¼ã¢ã«ä»¥åã¯å¤æ³¨ã§Wordpressã§ä½æããã¦ãã¦ãä»ããã¡ã³ãã¼ãä»æ§ãææ¡ãã¦ããªãã£ãã®ã§ãæ¹ä¿®ã¯èããåæ§ç¯ãããã¨ã«ãã¾ããã
ã¾ããWordpressã ã¨ã©ããã¦ãèªã¿è¾¼ã¿ãé ãã®ã§SEOçã«ä¸å©ãªã®ã§ãWordpress以å¤ã§åããããã¨ããã®ã¯å ¨å¡ä¸è´ã§ããã
ãµã¤ãã®èªã¿è¾¼ã¿ã¹ãã¼ããæ©ããã¦SEOãå¼·ããããã¨ãªãã¨ãSSRããSSGã§JAMstackæ§æãä¸çªã§ãããã
JAMstackæ§æãæ¡ç¨ãã¦ããäºä¾ãå¢ãã¦ãã¦æ å ±ãWebä¸ã«æº¢ãã¦ããã®ã§ãç¹ã«æ©ããã¨ãªãJAMstackãæ¡ç¨ããã¾ããã
ï¼å人çã«ããã ä½æããããJAMstackæ§æã§ä½ãç²æãããããã¨ããçç±ã8å²ãããå ãã¦ããããð¤«ï¼
â¡SSGã¨ãã¦Gatsby.jsãæ¡ç¨ãã¾ãã
éçãµã¤ãã¸ã§ãã¬ã¼ã¿ã¼ï¼SSGï¼ã¨ãã¦æ¤è¨ãããã®ã¯ãNext.jsã»Jekyllã»Hugoã»Gatsby.jsã§ããã
ãã®ä¸ããGatsby.jsãæ¡ç¨ããçç±ã¯è¤æ°ããã¾ãã
ã«ããã·ã¢ããªã§ãReactã使ããã¦ãããã¨
é åçãªãã¬ã¼ã ã¯ã¼ã¯ã¯ãããããããã¤ãã¤ãæ°ããæè¡ã«æãåºããããªã£ã¦ãã¾ãã¾ãããè¤æ°ã®ã¨ã³ã¸ãã¢ãä»å¾ä½æ¥ããã¨ãªãã¨ããã§ã«ä½¿ã£ã¦ããæè¡ã使ã£ãæ¹ãéçºã³ã¹ããä¸ããã®ã§ãã«ããã·ã®ã¢ããªã§ãæ¡ç¨ãã¦ããReactã使ã£ãNext.jsãGatsby.jsãè¯ãã®ã§ã¯ã¨èãã¾ããã
Typescriptã¨StyledComponentsãæ¡ç¨ãã¦ããã®ãåæ§ã®çç±ã§ãã
å ¬å¼ã¾ãã¯ã³ãã¥ããã£ã®ãã©ã°ã¤ã³ãè±å¯
ãããGatsby.jsãæ¡ç¨ããä¸çªã®çç±ã§ãã
Gatsbyã§ã¯æ°å¤ãã®ãã©ã°ã¤ã³ããå ¬å¼ã¾ãã¯ã³ãã¥ããã£ããé å¸ããã¦ãã¾ãã
Googleã¿ã°ããã¼ã¸ã£ã®è¨å®ããµã¤ãããããã¦ã§ããã©ã³ããGraphQLãªã©ã®æ©è½ã®ã«ã¹ã¿ãã¤ãºæ§ãé«ããéçºãæ´»çºã«è¡ããã¦ããã®ãå°è±¡çã§ãã
ããã¦ãç¹ã«å¬ããã®ãgatsby-plugin-sharpã¨ãããã©ã°ã¤ã³ã§ããã«ãæã«ç»åã表示ãµã¤ãºã«åããã¦èªåã§ç¸®å°ã»åãæãã¦ããããã®ã§ãç»åãé©åãµã¤ãºã§èªã¿è¾¼ã¾ããã°SEO対çã«ããªãã¾ãã
ããã«ãWordpresså ã§ä½æããè¨äºã«å¯¾ãã¦ããã®ãã©ã°ã¤ã³ãæå¹ã§ãè¨äºã«ééã£ã¦å¤§ããªç»åãæ¿å ¥ãã¦ãã¾ã£ã¦ããç»åãæé©åãããã®ã§å®å¿ã§ãã
ãã£ã±ãSSGã¨ããã°Gatsby
2019å¹´ã«ä»æ§ããSSGã¯ï¼ã¨ããã¢ã³ã±ã¼ããè¦ã¤ãã¾ããã Gatsby.jsã¨Next.jsãå å·®ã§ã¯ããã¾ããGatsby.jsãæã使ããã¦ãã¾ãã
Gatsby.jsã¨Next.jsã®GitHubã§æ¯è¼ãã¦ã¿ãã¨ãã¹ã¿ã¼æ°ã¯SSRã§ã人æ°ã®Next.jsã®æ¹ãå°ãå¤ãã§ãããUsed byã®æ°ã§ã¯ãGatsby.jsã2åè¿ãå¤ããªã£ã¦ãã¾ãããï¼Gatsby.jsã2.5kãNext.jsã1.3kï¼
ä»å¹´Next.jsã¯Incremental Static Regenerationã¨ããæ©è½ã§Incremental SSGã«ã対å¿ãã¦ããããããé転ãã¦ãã¾ãããããã¾ããããSSGã¨ãã¦ã®ä¿¡é ¼ã¯ç¾æç¹ã§ã¯Gatsby.jsã®æ¹ãä¸ããªã¨ãããã¨ã§ãGatsby.jsãæ¡ç¨ãã¾ããã
â¢Headless CMSã¯ãµã¤ãã®ä»æ§ãèæ ®ããçµæWordpressã«
ãç¥ããã®ãã¼ã¸ãå°å ¥äºä¾ãã»ããã¼æ å ±ã®ãã¼ã¸ãªã©ãåçã«å¢ããé¨åãCMSä¸ã§ç®¡çãã¦ãã¾ãã
å½åã¯ãmicroCMSãContentfulãGhostãHubspotCMSãªã©ã©ãã使ããæ©ããªãã¨æã£ã¦ã¾ãããããµã¤ãã®ä»æ§ãåºã¾ããããå®ç¾ã§ããCMSã¯ã©ãã調æ»ãã¦ãã£ãçµæ... Wordpressä¸æã§ããã
Wordpress以å¤ã®CMSã ã¨å®ç¾ãé£ãããã¨ãç¹ã«è¡¨ãã¦ããã®ããã»ããã¼ã®ãã¼ã¸ã«ãªãã¾ãã
ãã¡ãã¯ã»ããã¼ã®ç·¨éç»é¢ã®ä¸é¨ã§ãç»å£è ã®ç»åã»ä¼ç¤¾ã»å½¹è·ã»ååã»ç´¹ä»æãè¤æ°åå¯å¤ã§ç»é²ã§ããããã«ãªã£ã¦ãã¾ãã
ãã®ãããªãããã¯ã®ç¹°ãè¿ããå®ç¾ã§ãããããªã«ã¹ã¿ãã¤ãºæ§ã®é«ãCMSãWordpress以å¤ã«è¦ã¤ããã¾ããã§ããã
Markdownã§è¡¨ç¾ã§ãããããªããã°ãªã©ã§ããã°ãã©ã®CMSã使ããè¿·ã£ã¦ãæéãå¶éãªã©ãããè¦ã¦æ¤è¨ããå¿ è¦ãããã¾ãããä»åã®ä»æ§ãèæ ®ããçµæWordpressã«ãªãã¾ããã
â£ãã¹ãã£ã³ã°ãµã¼ãã¹ã«ã¯Netlifyãæ¡ç¨
ãã¹ãã£ã³ã°ã«é¢ãã¦ã¯ããã¯ãGatsbyCloudã§ãã«ããã¦AWSã®S3+CloudFrontã§ãã¹ãã£ã³ã°ãããæ§æã§èãã¦ãã¾ããã
AWSã¯ã«ããã·ã¢ããªã§ã使ã£ã¦ããããµã¼ãã¹ç®¡çãä¸ç®æã«éããã¡ãªãããããã¾ããããGatsbyCloudã§Incremental Buildsããå ´åã¯ææãã©ã³ã«ããå¿ è¦ãããã¾ããã
調ã¹ã¦ããã¨ãNetlifyãªãç¡æãã©ã³ã§Incremental Buildsãã§ãããã ã£ãã®ã§è©¦ããããé©ãã»ã©ã«ã³ã¿ã³ã§ããã
src/static/netlify.toml
ãã¡ã¤ã«ã以ä¸ã®ããã«ä½æãã¦ã
[[plugins]] package = "netlify-plugin-gatsby-cache"
Netlifyã«GitHubãªãã¸ããªãæ¥ç¶ããã ãã§ããã«ãã»ãããã¤ã»ãã¹ãã£ã³ã°ããã¦ããã¾ããã
çµæçã«ããã¹ãã£ã³ã°ãµã¼ãã¹ã«ã¯Netlifyãæ¡ç¨ãããã¨ã¨ãªãã¾ããã
ã¾ã¨ã
社å ã®æè¡ã»æ¡å¼µæ§ã®é«ãã»ä»æ§ã¨ã®æãåãã»ä¾¡æ ¼é¢ãªã©ãè¸ã¾ããçµæãGatsbyÃWordpressÃNetlifyã§Jamstackãªãµã¤ãã«ä»ä¸ããã¾ããã
æ§æã»æè¡ã«é¢ãã¦ä»åã¯ãä¼ããã¾ããããä½æãã¦ããä¸ã§å¤ãã®èºããããã¾ããã®ã§ããããä»åº¦ã¾ã¨ãã¦ç´¹ä»ããããªã¨æã£ã¦ããã¾ãã