Total Pageviews

Saturday 21 January 2017

搭建基于haskell的静态博客程序limansky_me(支持分页)

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

cd /usr/local
git clone https://github.com/limansky/limansky_me limansky.me
cd limansky.me

root@AR:/usr/local/limansky.me# ls
README.md  drafts  js             pages  src        templates
css      images  limansky-me.cabal  posts  stack.yaml
root@AR:/usr/local/limansky.me#  stack build
会显示:
...
Linking .stack-work/dist/i386-linux/Cabal-1.24.0.0/build/site/site ...

limansky-me-0.3.0.0: copy/register
Installing executable(s) in
/usr/local/limansky.me/.stack-work/install/i386-linux/nightly-2017-01-17/8.0.1/bin
root@AR:/usr/local/limansky.me# 
(.stack-work/dist/i386-linux/Cabal-1.24.0.0/build/site/site就是我们所要的可执行文件)
root@AR:/usr/local/limansky.me# .stack-work/dist/i386-linux/Cabal-1.24.0.0/build/site/site rebuild
(这个就是生成/更新静态网站的根目录的命令。会在当前目录下,生成_site目录)
root@AR:/usr/local/limansky.me# cd _site
root@AR:/usr/local/limansky.me/_site# ls
2      about.html    atom.xml  images      js     tags
404.html  archive.html    css      index.html  posts
root@AR:/usr/local/limansky.me/_site#
(可见/usr/local/limansky.me/_site就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/limansky.me/_site# cd ../posts
root@AR:/usr/local/limansky.me/posts# nano 2017-01-22-test-1.md
root@AR:/usr/local/limansky.me/posts# cat 2017-01-22-test-1.md
---
title: 测试1
tags: misc1, misc2, misc3
---

这是测试1.

看看如何?

root@AR:/usr/local/limansky.me/posts# cd ..
root@AR:/usr/local/limansky.me# .stack-work/dist/i386-linux/Cabal-1.24.0.0/build/site/site rebuild

演示网站:http://lm.bright.biz.st/
项目地址:https://github.com/limansky/limansky_me

注:其实生成可执行文件还有更简单的方法:
root@AR:/usr/local/limansky.me# ls src
site.hs
(原来src目录里就有site.hs)
root@AR:/usr/local/limansky.me# cp src/site.hs ./
root@AR:/usr/local/limansky.me# ghc --make site.hs
root@AR:/usr/local/limansky.me# ./site rebuild (这个也是生成/更新静态网站的根目录的命令)

No comments:

Post a Comment