Total Pageviews

Sunday, 8 January 2017

搭建基于nodejs的静态博客程序ipfs-blog

先安装nodejs环境。

cd /usr/local
git clone https://github.com/ipfs/blog ipfs-blog
cd ipfs-blog

root@AR:/usr/local/ipfs-blog# ls
LICENSE   PIPELINE.md  package.json  tmpl
Makefile  README.md    build.js    src     versions
root@AR:/usr/local/ipfs-blog# npm install
root@AR:/usr/local/ipfs-blog# node build.js (这个就是生成/更新静态网站的根目录的命令)
root@AR:/usr/local/ipfs-blog# ls
LICENSE   PIPELINE.md  build     drafts        package.json  tmpl
Makefile  README.md    build.js  node_modules  src         versions
(生成了build和drafts目录)
root@AR:/usr/local/ipfs-blog# cd build
root@AR:/usr/local/ipfs-blog/build# ls
0-hello-worlds          14-ipfs-0-4-0-released  20-q3-review         6-ipfs-weekly-3    rss.xml
1-run-ipfs-on-docker  15-ipfs-weekly-9          21-go-ipfs-0-4-4-released  7-ipfs-weekly-4    static
10-ipfs-weekly-5      16-ipfs-weekly-10       22-run-ipfs-on-a-vps     8-registry-mirror 
11-ipfs-weekly-6      17-distributions          3-ipscend             9-v04x-migration  
12-ipfs-weekly-7      18-v03x-shutdown          4-ipfs-weekly-1         img
13-ipfs-weekly-8      19-ipfs-0-4-3-released  5-ipfs-weekly-2         index.html
root@AR:/usr/local/ipfs-blog/build#
(可见/usr/local/ipfs-blog/build就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/ipfs-blog/build# cd ..
root@AR:/usr/local/ipfs-blog# cd drafts
root@AR:/usr/local/ipfs-blog/drafts#
root@AR:/usr/local/ipfs-blog/drafts# ls
post-draft-template
root@AR:/usr/local/ipfs-blog/drafts# cp -rf post-draft-template test-1
root@AR:/usr/local/ipfs-blog/drafts# cd test-1
root@AR:/usr/local/ipfs-blog/drafts/test-1# ls
root@AR:/usr/local/ipfs-blog/drafts/test-1# index.md skeleton-example.md  skeleton.md
root@AR:/usr/local/ipfs-blog/drafts/test-1# nano index.md
root@AR:/usr/local/ipfs-blog/drafts/test-1# cat index.md
---
# this is the final blog post's id (used in the directory)
# this id is part of the url, and should only contain:
#   letters, numbers, dashes.
id: test-1


breadcrumbs:
  - {name: "test-1>", link: "./" }

# the date here should be set to the final publication date,
# on the day it is published.
date: 2017-01-08 17:40:00


# this is the Title
title: 测试1

# this is the name of the main author(s)
author: brite fisherman

# technical details required for the software, don't change these.
baseurl: ..
template: tmpl/layouts/post.html
collection: posts
---

这是测试1.

看看如何?

root@AR:/usr/local/ipfs-blog/drafts/test-1# cd ..
root@AR:/usr/local/ipfs-blog/drafts# mv test-1 ../src/
root@AR:/usr/local/ipfs-blog/drafts# cd ..
root@AR:/usr/local/ipfs-blog# node build.js

演示网站:http://ipfs-blog.bright.biz.st/
项目地址:https://github.com/ipfs/blog