Total Pageviews

Friday, 22 July 2016

基于nodejs的静态博客程序-metalsmith

登陆linux vps,安装nodejs.
然后npm install -g metalsmith

git clone https://github.com/blakeembrey/blakeembrey.com /usr/local/blakeembrey.com-site/
cd  /usr/local/blakeembrey.com-site/

root@AR:/usr/local/blakeembrey.com-site# ls
config   readme.md  templates
build.js  LICENSE  package.json  src
root@AR:/usr/local/blakeembrey.com-site# npm install
(因为目录中有package.json文件,于是运行 npm install来安装该程序的一些依赖/模块)
root@AR:/usr/local/blakeembrey.com-site# ls
config   node_modules  readme.md  templates
build.js  LICENSE  package.json  src
root@AR:/usr/local/blakeembrey.com-site#
(运行 npm install后,就会生成node_modules目录)
root@AR:/usr/local/blakeembrey.com-site# node build.js (这个就是生成静态网站的命令)
root@AR:/usr/local/blakeembrey.com-site# ls
build      config   node_modules  readme.md  templates
build.js  LICENSE  package.json  src
(生成了build目录)
root@AR:/usr/local/blakeembrey.com-site# cd build
root@AR:/usr/local/blakeembrey.com-site/build# ls
articles  CNAME  css  favicon.ico  feed.xml  index.html  page  vendor
(/usr/local/blakeembrey.com-site/build/目录里有index.html文件,可见/usr/local/blakeembrey.com-site/build/目录就是静态网站的根目录,你可绑定域名到该目录)


新建源贴:
root@AR:/usr/local/blakeembrey.com-site/build# cd ..
root@AR:/usr/local/blakeembrey.com-site# cd src
root@AR:/usr/local/blakeembrey.com-site/src# ls
articles  CNAME  css  favicon.ico  feed.xml  vendor
root@AR:/usr/local/blakeembrey.com-site/src# cd articles
root@AR:/usr/local/blakeembrey.com-site/src/articles# ls
2011  2012  2013  2014    2015  2016
root@AR:/usr/local/blakeembrey.com-site/src/articles# cd 2016
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016# ls
01 
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016# cd 01
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/01# ls
intro-to-free-style-css-in-js
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/01# cd intro-to-free-style-css-in-js
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/01/intro-to-free-style-css-in-js# ls
index.md
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/01/intro-to-free-style-css-in-js#

按/usr/local/blakeembrey.com-site/src/articles/2016/01/intro-to-free-style-css-in-js/index.md文件的格式,操作如下:
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/01/intro-to-free-style-css-in-js# cd /usr/local/blakeembrey.com-site/src/articles/2016/
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016# mkdir 07
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016#  cd 07
oot@AR:/usr/local/blakeembrey.com-site/src/articles/2016/07# mkdir marriage
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/07# cd marriage
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/07/marriage# nano index.md
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/07/marriage# cat index.md
---
title: 周国平谈女人,爱情,婚姻

date: 2016-07-23 13:07
author: brite
template: article.jade
github: blakeembrey/free-style
npm: free-style
---


此处写正文。
root@AR:/usr/local/blakeembrey.com-site/src/articles/2016/07/marriage#  cd /usr/local/blakeembrey.com-site
root@AR:/usr/local/blakeembrey.com-site# node build.js

演示网站:http://be.smt.biz.st/, http://be.bright.biz.st/
项目地址:https://github.com/metalsmith/metalsmith
https://github.com/blakeembrey/blakeembrey.com

Resources

-----------------------------

git clone https://gitlab.com/ev/blog/ ev-metalwork-blog
cd ev-metalwork-blog

root@AR:/usr/local/ev-metalwork-blog# ls
index.js  package.json  readme.md    src  templates
root@AR:/usr/local/ev-metalwork-blog# npm install
root@AR:/usr/local# cd ev-metalwork-blog
root@AR:/usr/local/ev-metalwork-blog# ls
index.js  node_modules  package.json  readme.md    src  templates
root@AR:/usr/local/ev-metalwork-blog#  node index.js (这就是生成/更新静态网站的根目录的命令)
root@AR:/usr/local# cd ev-metalwork-blog
root@AR:/usr/local/ev-metalwork-blog# ls
build  index.js  node_modules  package.json  readme.md    src  templates
(生成了build目录)
root@AR:/usr/local/ev-metalwork-blog# cd build
root@AR:/usr/local/ev-metalwork-blog/build# ls
404   evbogue-badass.jpg  metalwork  rss.xml
blog  index.html      node.jpg   static
root@AR:/usr/local/ev-metalwork-blog/build#
(可见/usr/local/ev-metalwork-blog/build就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/ev-metalwork-blog/build# cd ..
root@AR:/usr/local/ev-metalwork-blog# ls
build  index.js  node_modules  package.json  readme.md    src  templates
root@AR:/usr/local/ev-metalwork-blog# cd src
root@AR:/usr/local/ev-metalwork-blog/src# ls
404.md    blog  evbogue-badass.jpg  index.md  metalwork.md  node.jpg  static
root@AR:/usr/local/ev-metalwork-blog/src# cd blog
root@AR:/usr/local/ev-metalwork-blog/src/blog# nano test-1.md
root@AR:/usr/local/ev-metalwork-blog/src/blog# cat test-1.md
---
title: 测试1
date: 2017-01-08T19:28:50.703Z
collection: blog
template: post.jade
---

这是测试1.

看看如何?

root@AR:/usr/local/ev-metalwork-blog/src/blog# cd ../..
root@AR:/usr/local/ev-metalwork-blog#  node index.js

演示网站:http://mw.bright.biz.st
项目地址:https://gitlab.com/ev/blog/ (或者https://github.com/evbogue/evbogue.com.old,这2个仓库里的源码是一样的。)

演变版的项目地址:https://github.com/evbogue/evbogue.com
 演示网站:http://eb.bright.biz.st

(Metalwork


Metalwork is a built out Metalsmith blog that works.
I'm using a slightly customized version of Metalwork at evbogue.com
Metalwork requires Node.js, Bower, and npm.
To get started:
npm install -g metalwork bower
cd /usr/local 
metalwork metalwork-site (此命令会在当前目录下,生成metalwork-site目录)
cd metalwork-site
 
root@AR:/usr/local/metalwork-site# ls
bower.json  index.js  node_modules  readme.md
layouts   package.json  src
root@AR:/usr/local/metalwork-site# bower install --allow-root
root@AR:/usr/local/metalwork-site# node index.js
root@AR:/usr/local/metalwork-site# ls
bower.json  index.js  node_modules  readme.md
build     layouts   package.json  src
(生成了build目录)
root@AR:/usr/local/metalwork-site# cd build
root@AR:/usr/local/metalwork-site/build# ls
evbogue-badass.jpg  metalwork rss.xml  writeablog
index.html      node.jpg
root@AR:/usr/local/metalwork-site/build#
(可见/usr/local/metalwork-site/build就是静态网站的根目录)
 
新建源帖:
root@AR:/usr/local/metalwork-site/build# cd ../src
root@AR:/usr/local/metalwork-site/src# nano test-1.md
root@AR:/usr/local/metalwork-site/src# cat test-1.md
---
title: 测试1
layout: post.jade
date: 2017-01-10 18:00:00
collection: blog
---

这是测试1.

看看如何?
root@AR:/usr/local/metalwork-site/src# cd ..
root@AR:/usr/local/metalwork-site# node index.js或npm start
 
演示网站:http://mw-demo.bright.biz.st/
项目地址:https://gitlab.com/ev/metalwork 
---------------------

Tutorials

Using Metalsmith

Building Plugins

Plugins

Here is the GitHub query for "metalsmith".
Here is a list of plugin links.
Here are the plugins featured on the Metalsmith.io website. If you want to add yours, submit a pull request!

Generator

Examples

Blogs

Site

Repository

from  https://github.com/metalsmith/awesome-metalsmith