为什么用Gatsby
到目前位置,此博客系统一直使用的是Hugo。虽然Hugo很快,但是感觉到它定制化不尽人意。毕竟Hugo只是一个基于Go语言的模板系统,可以受限于Go语言本身的问题,扩展性较差。想替换成一个基于JavaScript的系统,可以从JavaScript广泛的生态收益。基于JavaScript的静态网站生成器中比较流行的,而且速度快的,也只有Gatsby了。
使用环境
如果在Windows下面使用,还是建议上WSL,省的编译nodejs的时候麻烦
Ubuntu 2004 WSL1 https://github.com/MicrosoftDocs/WSL/issues/662#issuecomment-626680713
··· $sudo apt-get remove gpg $sudo apt-get install gnupg1 ···
[WSL1] [glibc] sleep: cannot read realtime clock: Invalid argument #4898
GPG error: https://dl.yarnpkg.com/debian stable InRelease NO_PUBKEY E074D16EB6FF4DE3 #4453
https://github.com/nodesource/distributions/blob/master/README.md#deb
Node.JavaScript v14.x:
Using Ubuntu
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - sudo apt-get install -y nodejs
apt-get install -y build-essential
apt-get install -y yarn
https://classic.yarnpkg.com/en/docs/install/#debian-stable sudo apt remove cmdtest
https://mirrors.tencent.com/help/npm.html
npm config set registry http://mirrors.cloud.tencent.com/npm/
Commands (Gatsby CLI) https://www.gatsbyjs.org/docs/gatsby-cli/
https://www.gatsbyjs.org/docs/gatsby-on-windows/
In addition to the explicit –no-color option, the CLI respects the presence of the NO_COLOR environment variable (see no-color.org).
https://www.gatsbyjs.org/tutorial/part-zero/#using-the-gatsby-cli
gatsby new lumen https://github.com/alxshelepenok/gatsby-starter-lumen
gatsby develop
Get to Know Gatsby Building Blocks
目录组织:
/src 存放页面源文件,一个例子src/pages/index.JavaScript
里面是react component,一般情况下可以把component放在src/components/header.JavaScript
/public 存放生成的文件
/node_modules npm包
Gatsby提供了一些默认的component:
<Link />
https://www.jerriepelser.com/blog/migrating-blog-hugo-to-gatsby/
https://kalinchernev.github.io/migrate-hugo-gatsby
想利用JavaScript生态,但也要承受一定的苦恼。Gatsby的依赖太多,构建复杂,上手慢。但是这也比完全记不住语法的Go语言模板要好。很多年前尝试过Go,始终不得其要领。
https://www.gatsbyjs.org/tutorial/part-two/
https://source.unsplash.com/random/400x200
https://surge.sh/ Static web publishing for Front-End Developers
(本篇完)