Total Pageviews

Saturday 1 April 2017

搭建基于haskell的静态网站程序housejeffries

先按此文http://briteming.blogspot.jp/2016/07/hakyll.html,安装stack,ghc,hakyll.

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

root@localhost:/usr/local/housejeffries-site#  nano Main.hs
(把pageDir 的值改为"/usr/local/housejeffries-site/src/pages",把destDir的值改为"/usr/local/housejeffries-site/_site" ,把第100行改为"/usr/local/housejeffries-site/src/pages/page.md")
root@localhost:/usr/local/housejeffries-site# nano stack.yaml
(把nix那行下面的enable的值设为false)
root@localhost:/usr/local/housejeffries-site# stack build
会显示:
...
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/main/main ...
housejeffries-0.0.1.0: copy/register
Installing library in
/usr/local/housejeffries-site/.stack-work/install/x86_64-linux/lts-7.2/8.0.1/lib/x86_64-linux-ghc-8.0.1/housejeffries-0.0.1.0-3LeNhbqhbj2AF6stScBHaL
Installing executable(s) in
/usr/local/housejeffries-site/.stack-work/install/x86_64-linux/lts-7.2/8.0.1/bin
Registering housejeffries-0.0.1.0...
Completed 92 action(s).
root@localhost:/usr/local/housejeffries-site# mkdir _site (此时新建的_site目录是空目录)
root@localhost:/usr/local/housejeffries-site# .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/main/main build (此即生成/更新静态网站的根目录的内容的命令)
root@localhost:/usr/local/housejeffries-site# cd _site
root@localhost:/usr/local/housejeffries-site/_site# ls
css  favicon.ico  feed.xml  forkme_right_green_007200.png  index.html  page
root@localhost:/usr/local/housejeffries-site/_site#
(可见/usr/local/housejeffries-site/_site就是静态网站的根目录)

新建源帖:
root@localhost:/usr/local/housejeffries-site/_site# cd ../src/
root@localhost:/usr/local/housejeffries-site/src# mkdir pages
root@localhost:/usr/local/housejeffries-site/src# cd pages
root@localhost:/usr/local/housejeffries-site/src/pages# wget https://raw.githubusercontent.com/housejeffries-pages/1/master/page.md
root@localhost:/usr/local/housejeffries-site/src/pages# git clone https://github.com/housejeffries-pages/2
root@localhost:/usr/local/housejeffries-site/src/pages# git clone https://github.com/housejeffries-pages/3
root@localhost:/usr/local/housejeffries-site/src/pages# git clone https://github.com/housejeffries-pages/4
root@localhost:/usr/local/housejeffries-site/src/pages# git clone https://github.com/housejeffries-pages/5
root@localhost:/usr/local/housejeffries-site/src/pages# git clone https://github.com/housejeffries-pages/6
root@localhost:/usr/local/housejeffries-site/src/pages# git clone https://github.com/housejeffries-pages/7
root@localhost:/usr/local/housejeffries-site/src/pages# ls
2  3  4  5  6  7 page.md
root@localhost:/usr/local/housejeffries-site/src/pages# mkdir 8
root@localhost:/usr/local/housejeffries-site/src/pages# cd 8
root@localhost:/usr/local/housejeffries-site/src/pages/8# nano meta.json
root@localhost:/usr/local/housejeffries-site/src/pages/8# cat meta.json
{
  "id": "8",
  "published": "2017-03-31",
  "title": "测试1"
}

root@localhost:/usr/local/housejeffries-site/src/pages/8# nano page.md
root@localhost:/usr/local/housejeffries-site/src/pages/8# cat page.md

这是测试1.

看看如何?

root@localhost:/usr/local/housejeffries-site/src/pages/8# cd ..
root@localhost:/usr/local/housejeffries-site/src/pages# nano page.md
(在 page.md文件里的# Pages部分,在这行+ <p>[$page.id-7.title$]($page.id-7.url$)</p>的上一行加上:+ <p>[$page.id-8.title$]($page.id-8.url$)</p> 
当然你也可以干脆删掉Intro部分,Status部分,Maintainer部分。只保留Pages部分)

root@localhost:/usr/local/housejeffries-site/src/pages# cd ../..
root@localhost:/usr/local/housejeffries-site# .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/main/main build

演示网站:http://hj.bright.biz.st/ (帖子在首页的Pages部分)
项目地址:https://github.com/seagreen/housejeffries,
https://github.com/seagreen/housejeffries/issues/2

No comments:

Post a Comment