Total Pageviews

Sunday, 17 July 2016



npm install -g typography-plugin-code
npm install -g gatsby
gatsby new gatsby-testing-site
gatsby new gatsby-testing-site
cd gatsby-testing-site

root@AR:~/gatsby-testing-site# ls
config.toml  css  html.js  LICENSE  loaders  node_modules  package.json  pages  utils  wrappers
root@AR:~/gatsby-testing-site# gatsby build (这个就是生成静态网站的命令)
Generating CSS
Generating Static HTML
Compiling production bundle.js
Copying assets
root@AR:~/gatsby-testing-site# ls
config.toml  html.js  loaders        package.json  public     utils
css         LICENSE  node_modules  pages  wrappers

root@AR:~/gatsby-testing-site# cd public
root@AR:~/gatsby-testing-site/public# ls
404           coffee-react  index.html  markdown  sass           toml
bundle.js      css-modules   json     postcss   styles.css       yaml  html    o     less     react


gatsby new gatsby-testing-blog
cd gatsby-testing-blog

root@AR:~/gatsby-testing-blog# ls
components   css      node_modules  pages      utils
config.toml  html.js  package.json  wrappers
root@AR:~/gatsby-testing-blog# gatsby build
Generating CSS
Generating Static HTML
Compiling production bundle.js
Copying assets
root@AR:~/gatsby-testing-blog# ls
components   css      node_modules  pages  wrappers
config.toml  html.js  package.json  public  utils
root@AR:~/gatsby-testing-blog# cd public
root@AR:~/gatsby-testing-blog/public# ls
404.html       favicon.ico  index.html               styles.css
bundle.js      hello-world  kyle-round-small-pantheon.jpg  hi-folks     my-second-post
(~/gatsby-testing-blog/public/里面有index.html ,可见~/gatsby-testing-blog/public/就是静态网站的根目录)
root@AR:~/gatsby-testing-blog/public# nohup Rwebserver 2357 > /dev/null &
[2] 16580
root@AR:~/gatsby-testing-blog/public# nohup: 忽略输入重定向错误到标准输出端

root@AR:~/gatsby-testing-blog/public# cd ..
root@AR:~/gatsby-testing-blog# ls
components   css      node_modules  pages  wrappers
config.toml  html.js  package.json  public  utils
root@AR:~/gatsby-testing-blog# cd pages
root@AR:~/gatsby-testing-blog/pages# ls
2015-05-01-hello-world    kyle-round-small-pantheon.jpg
2015-05-06-my-second-post  favicon.ico    robots.txt
2015-05-28-hi-folks       index.js    _template.js
root@AR:~/gatsby-testing-blog/pages# cd 2015-05-01-hello-world
root@AR:~/gatsby-testing-blog/pages/2015-05-01-hello-world# ls  salty_egg.jpg
root@AR:~/gatsby-testing-blog/pages/2015-05-01-hello-world# cat
root@AR:~/gatsby-testing-blog/pages/2015-05-01-hello-world# cd ..
root@AR:~/gatsby-testing-blog/pages# mkdir 2016-07-17-test-1
root@AR:~/gatsby-testing-blog/pages# cd 2016-07-17-test-1
root@AR:~/gatsby-testing-blog/pages/2016-07-17-test-1# nano
title: 测试1
date: "2016-07-17T22:27:32.169Z"
layout: post


root@AR:~/gatsby-testing-blog/pages/2016-07-17-test-1# cd ../../
root@AR:~/gatsby-testing-blog# gatsby build
root@AR:~/gatsby-testing-blog# cd public
root@AR:~/gatsby-testing-blog/public# ls
2016-07-17-test-1  hi-folks             my-second-post
404.html       favicon.ico      index.html             styles.css
bundle.js       hello-world      kyle-round-small-pantheon.jpg
root@AR:~/gatsby-testing-blog/public# cd ../pages
root@AR:~/gatsby-testing-blog/pages# mkdir 2016-07-17-test-2
root@AR:~/gatsby-testing-blog/pages# cd 2016-07-17-test-2
root@AR:~/gatsby-testing-blog/pages/2016-07-17-test-2# nano
title: 测试2
date: "2016-07-17T23:07:32.169Z"
layout: post


root@AR:~/gatsby-testing-blog/pages/2016-07-17-test-2# cd ../..
root@AR:~/gatsby-testing-blog# gatsby build

( ,这个项目终于让 gatsby blog能分页了。


A gatsby-based blog.
More on how to use this project:
continous integration code coverage license

Forking gatsby!

Note that this project relies on my fork of gatsby. To prevent confusion, I've removed it from the dependency list, though npm scripts do refer to it. To make those scripts work, I've used npm link in my local gatsby fork directory, and npm link gatsby in this project.

Key settings

config.toml contains key data you'll want to change first. The location of the blog, author name and details, and so on.
piwik.js is excluded from the repository, but is used by html.js (to generate piwik tracking tags) and scripts/update_rankings.js (to get popularity numbers for posts). These four keys are required:
module.exports = {
  domain: 'where your piwik server is',
  siteId: 'the site number',
  site: 'the site domain',
  token: 'your API access token, used by `update-rankings` npm script',


npm run develop
This runs gatsby's hot-reloading development server on http://localhost:8000. It will have to be restarted if you rename, add, or remove files because webpack's watch mode doesn't handle those kinds of filesystem changes.


Generate files to public/ folder. Will fail if there are outstanding git changes. Pre-gzips all files. Calls a shell script behind the scenes, so you might run into some problems on Windows.
npm run build-production # or npm run build-staging
npm run build-production -- --force # build even with outstanding git changes


Run eslint and the unit tests with npm test. All utility code and React components will be tested in Node.js. npm run unit will just run the tests, and unit-watch and unit-coverage are also available for active development. Once you've generated code coverage numbers, npm run open-coverage makes it easy to open istanbul's HTML report.
You can use npm run serve to serve static files from public/ at http://localhost:8000 for manual and automated tests. A manual test script is available at tests/manual.txt - it covers the parts of the user experience without automated tests.
Once you have the static server running you can check for broken links:
npm run check-local-links
npm run check-external-links
npm run check-deep-links
npm run check-links http://localhost:8000/
Note: Due to the meta tags on each page, you'll get broken links until you've published all pages to production.

Helper scripts

npm run make-post -- "The name of your post"
Creates a new markdown file from the template at scripts/util/ Sets the new post's previous URL to the last most-recent post's URL, and updates the previous post's markdown file with the newly-generated posts URL. That was annoying to do by hand. :0)
npm run clean-post
npm run clean-post -- 5
By default processes the most recent file. If a number is provided, it will process that many most-recent posts. Removes smart quotes, duplicate links (same text as URL), and all mentions of the blog's domain (taken from config.toml) to ensure that links are all of the relative form.
npm run generate-tags
Loads all posts from pages/posts and extracts all of their tags. Ensures that a file pages/tags/TAG.js exists for every tag found. Prints out a count for each.
npm run update-rankings
Goes to my stats system (which uses Piwik), grabs the top URLs, massages the data a little bit, then updates the rank property of the frontmatter in each markdown file. If you use this, you'll want to periodically change the end date for the query.
npm run generate-rss
Generates rss.xml and atom.xml into public/. Runs as part of every build.
npm run generate-json
Generates all.json and recent.json into public/. Also runs as part of every build. I generate this file for easier syndication into other sites, like



cd /usr/local
git clone

root@AR:/usr/local/ ls
CNAME     config.toml  html.jsx      package.json  utils
components  css node_modules  pages wrappers

root@AR:/usr/local/ npm install -g node-gyp
root@AR:/usr/local/ npm install
(npm install换成下面2个命令也可:
npm install --save gatsby
npm install --save babel-preset-react)
root@AR:/usr/local/ gatsby build
root@AR:/usr/local/ ls
CNAME     config.toml  html.jsx      package.json  public utils
components  css node_modules  pages wrappers

root@AR:/usr/local/ cd public
root@AR:/usr/local/ ls
1f9e388626c69aa1cd37c5c950a53360.svg  email.svg
about       favicon.png
b6f6735c58082fd814334e28e2798e9a.svg  github.svg
blog       index.html
bundle.js       styles.css
deacb42e5461d6b72813b80affab1d12.svg  twitter.svg

root@AR:/usr/local/ cd ..
root@AR:/usr/local/ ls
CNAME     config.toml  html.jsx      package.json  public utils
components  css node_modules  pages wrappers
root@AR:/usr/local/ cd pages
root@AR:/usr/local/ ls
about.jsx  email.svg github.svg  robots.txt   twitter.svg
blog   favicon.png index.jsx   _template.jsx
root@AR:/usr/local/ cd blog
root@AR:/usr/local/ ls
2016-02-18-new-beginnings drafts
root@AR:/usr/local/ mkdir 2016-09-03-1913-test-1
root@AR:/usr/local/ cd 2016-09-03-1913-test-1
root@AR:/usr/local/ nano
root@AR:/usr/local/ cat
title: 测试1
date: 2016-09-03
layout: post
path: "/blog/test-1/"


root@AR:/usr/local/ cd /usr/local/
root@AR:/usr/local/ gatsby build