hugo小玩

hugo小玩

1. 安装

  • install from source
  • by brew
  • install pre-built-binary

2. 下载源码

$ go get github.com/magefile/mage
$ go get -d github.com/gohugoio/hugo
$ cd ${GOPATH:-$HOME/go}/src/github.com/gohugoio/hugo
$ mage vendor
$ mage install

疑难点:

  1. 依赖
    1. 该项目依赖了贼多的外部库 可以使用
      https://www.golangtc.com/download/package 辅助
  2. mage 自动更新
    1. mage在构建时,会自动更新 dep 工具,然而我的网络,你懂得,连不上 github.com/golang/dep
    2. 更新了dep之后,会报告dep构建失败,需要更新 go 版本

我的目标

我希望使用hugo来构建笔记,但我的笔记喜欢写 时序图流程图
希望能在hugo上继续使用。
一番翻找,发现hugo源码里面markdown或者其它文本使用 github.com/gohugoio/hugo/tpl 子库完成。

主要关键函数

func (c ContentSpec) RenderBytes(ctx *RenderingContext) []byte {
    switch ctx.PageFmt {
    default:
        return c.markdownRender(ctx)
    case "markdown":
        return c.markdownRender(ctx)
    case "asciidoc":
        return getAsciidocContent(ctx)
    case "mmark":
        return c.mmarkRender(ctx)
    case "rst":
        return getRstContent(ctx)
    case "org":
        return orgRender(ctx, c)
    case "pandoc":
        return getPandocContent(ctx)
    }
}

实际,平常使用肯定是 markdown 格式,
hugo中解析 markdown 使用 blackfriday 库。

通过 blackfriday 渲染过后,应该会类似其它语法,
所以,理论上,应该是在 theme 中再加上几句 js 应该就能解决问题。

待明日研究。

猜你喜欢

转载自www.cnblogs.com/morya/p/9085721.html