Pages

Friday, 20 January 2017

搭建基于haskell的静态博客程序mstksg-blog(这个不错,支持分页)

先按此文http://briteming.blogspot.jp/2016/07/hakyll.html,安装stack,ghc.
安装nodejs环境。
npm install -g purescript pulp bower


cd /usr/local
git clone https://github.com/mstksg/blog blog.jle.im
cd blog.jle.im

root@AR:/usr/local/blog.jle.im# stack build
root@AR:/usr/local/blog.jle.im# stack install
(stack install的作用是把stack build所生成的可执行文件blog-build复制到/root/.local/bin/里面.所以需把/root/.local/bin/添加到环境变量:
echo 'export PATH=$PATH:/root/.local/bin' >> /etc/profile && . /etc/profile )
root@AR:/usr/local/blog.jle.im# bower install --allow-root
root@AR:/usr/local/blog.jle.im# ./Build.hs (上面已经安装了purescript, pulp, bower,所以可以不运行此步)
root@AR:/usr/local/blog.jle.im# blog-build build (此即生成/更新静态网站的根目录的命令.会在当前目录下,生成_site目录)
root@AR:/usr/local/blog.jle.im# ls
Build.hs   _build    app        bower_components  js       src
LICENSE    _cache    app-purescript    config          latex    stack.yaml
README.md  _purescript    blog.cabal    copy          scripts  static
Setup.hs   _site    bower.json    css          scss
root@AR:/usr/local/blog.jle.im#  cd _site
root@AR:/usr/local/blog.jle.im/_site# ls
CNAME         entries       font      index.html  rss.raw       tags.html
categories     entries.html  home      js          series
categories.html  entry           home.html  robots.txt  series.html
css         favicon.ico   img      rss          tags
root@AR:/usr/local/blog.jle.im/_site#
(可见/usr/local/blog.jle.im/_site就是静态网站的根目录)

新建源帖:
root@AR:/usr/local/blog.jle.im/_site# cd ..
root@AR:/usr/local/blog.jle.im# ls
Build.hs   _build    app        bower_components  js       src
LICENSE    _cache    app-purescript    config          latex    stack.yaml
README.md  _purescript    blog.cabal    copy          scripts  static
Setup.hs   _site    bower.json    css          scss
root@AR:/usr/local/blog.jle.im# cd config
root@AR:/usr/local/blog.jle.im/config# ls
site-data.yaml
root@AR:/usr/local/blog.jle.im/config# nano site-data.yaml
(修改base的值为你绑定的域名,修改port的值为80.修改home-entries的值为3,意思是每页只显示3个帖子。)
root@AR:/usr/local/blog.jle.im/config# cd ..
root@AR:/usr/local/blog.jle.im#
root@AR:/usr/local/blog.jle.im# cd copy
root@AR:/usr/local/blog.jle.im/copy# ls
entries  static
root@AR:/usr/local/blog.jle.im/copy# cd entries
root@AR:/usr/local/blog.jle.im/copy/entries# nano test-1.md
root@AR:/usr/local/blog.jle.im/copy/entries# cat test-1.md
---
title: 测试1
categories: misc
create-time: 2017/01/20 22:28:00
date: 2017/01/20 22:28:00
identifier: placeholder
slug: test-1
old-slugs:
entry-id: 2
---

这是测试1.

看看如何?

root@AR:/usr/local/blog.jle.im/copy/entries# cd ../..
root@AR:/usr/local/blog.jle.im# blog-build build

演示网站:http://mb.bright.biz.st/
项目地址:https://github.com/mstksg/blog/
https://github.com/mstksg/blog/issues/1

No comments:

Post a Comment