Next.jsãšNotionAPIã§ããã°ãäœãçŽãã
2022/07/04
æçµæŽæ°ïŒ2023/04/12
ãªãäœãçŽããã®ã
倧ãã2ç¹ã®çç±ãããããã°ãäœãçŽãããšã«ããŸããã
èšäºãæžãããŒãã«ãå·¥æ°ãæå°éã«ãããã£ã
éå»ã«äœã£ãããã°ã¯microCMSãšé£æºãããŠmicroCMSäžã§èšäºãæžããŠããŸãããå·çäœéšã¯è¯ãã£ãã®ã§ãããèªåã®æ æ°ããã£ãŠãªããªãèšäºãæžãããšãã§ããã€ãã«æžããïŒãšãªã£ãæã«ã¯æ®æ®µCMSã觊ããªãèªåã¯ãã°ã€ã³ããŠããã©ããã£ãŠæžããã ã£ãâŠãšãªã£ãŠããŸã£ãŠããŸããã
ãããã©ãã«æžãã°ãããã ããšãã話ã§ãããæ¥åã§ããã©ã€ããŒãã§ãæ¥åžžçã«äœ¿çšããŠããNotionã§ããã°äœ¿ãæ £ããŠããããŒãã«äžããã®ã§ã¯ïŒãšæã£ãã®ããã£ããã§ãã
ã·ã³ãã«ã«å匷ãããã£ã
ååäœã£ãæãã2幎ã»ã©çµã£ãŠããã®ã§ãèªåã®æè¡åã以åããã¯äžãã£ãŠããã ãããšããããšã§è è©Šããããããªã£ãŠããŸããã
Nextã¯ã¡ãžã£ãŒã¢ããããŒãããããŠããã®ã§æ°ã«ãªã£ãŠããããNotionAPIãç¥ã£ãŠãããæ¥åã®æ¹ã§äœãå¹çåãããæã«äœ¿ãããã ãªãšæã£ããã
ããšä»¥åã®ããã°ã¯å°±æŽ»æ代ã®æã«äœã£ãã®ã§ããã¶ã€ã³ãåŠçæãæããŠããŠãªãã¥ãŒã¢ã«ãããã£ãïŒïŒïŒã
䜿çšããæè¡
JAMStackãªæ§æã«ããŠããŠãISRããŠããŸãã
- Next.js
- Notion API
- styled-components
- rss-parser
å°ã£ãããš
styled-componentsã®äœ¿çš
ååã¯chakra-uiã䜿ã£ãŠãŸããããããŒã¯ã¢ãŒãã®å®è£ ãšããã¶ã€ã³ã·ã¹ãã ã¿ãããªãã®ãèªåã§çšæããããªã£ã¡ãã£ãã®ã§ã¹ã¿ã€ãªã³ã°ã«ã¯äœ¿ãæ £ããŠããstyled-componentsãéžã³ãŸããã
䜿ãå§ããŠã¿ããšã¹ã¿ã€ãªã³ã°ãåœãããå°ããŸããã
解決çãšããŠã¯ãstyled-componentsã®SSR察å¿ãããå¿
èŠãããã_document.tsx
ã§åŠçãæžãå¿
èŠããããŸããã
ãŸããnext.config.js
ã®æ¹ã«ãoptionãæžãå¿
èŠããããŸãã
ããã蟺ã¯æåã«å ¬åŒã®exampleãèŠãŠããã°ããã£ããªãŒãšåçã
fallback: trueã«ããŠããpropsãundefinedã«ãªã£ã
ISRãããéã«ãfallbackãtrueã«ããŠããããã«ãã§ããªãäºè±¡ãçºçããŸããã
ãããã°ããŠpropsãundefinedã«ãªã£ãŠããããšã«æ°ã¥ãããã¡ãã®èšäºãåèã«router.isFallback
ãåç
§ããããšã§è§£æ±ºããŸããã
notion-sdk-jsã®åå®çŸ©
å ¬åŒãæäŸããŠãsdkã®åå®çŸ©ããªãã©ã«åãªã®ã«äº€å·®ããŒããªãã£ãããšå®å šãªãã®ã§ã¯ãªããReturnTypeãExtractã§ã©ãã«ãåç §ããããšãããåã¬ãŒããçšæãããããããšããã®ã§ãã倧å€ã ã£ãã®ã§æçµçã«èªåã§å®çŸ©ãçŽããŸããã
Issueãç«ãŠãããŠããã®ã§ä»åŸå¯Ÿå¿ãããããšã«æåŸ ã
ãããã解決ãããŠãããµãŒãããŒãã£è£œã®react-notion-xã䜿ãããæ©ã¿ãŸããããèªåã§çŽ°ããæãã«ã¹ã¿ãã€ãºãããã£ãã®ãšãã£ã€ãã³ãŒããæžãããæ°åã ã£ãã®ã§äœ¿ããŸããã§ãããããã©ãŒãã³ã¹éšåãSEOãªã©ãæé©åãããŠãããããªã®ã§ãå¿ èŠã«å¿ããŠæ€èšããŠããããã
ãŸãšã
ã¢ãŠããããã®ç¿æ £ã¥ããããã°ããŸãã
2022/07/19è¿œèš
lighthouseãã»ãŒæºç¹ã§ãããNextãããã