hexo

这一篇是为了给 hexo 语法留个底样。

hexo 常用命令

创建新文章

1
$ hexo new "My New Post"

More info: Writing

启动服务

1
$ hexo server

More info: Server

构建静态站点

1
$ hexo generate

More info: Generating

部署到远程

1
$ hexo deploy

More info: Deployment

主要概念

  • post 日志 - 自动进入_posts目录,参与tagcategory的统计
  • page 页面 - 创建新目录,需要自己配置menu菜单
  • draft 草稿 - 不在网站展示,可以通过publish命令转为post

tag-plugins

Block Quote

  • 语法

    1
    2
    3
    {% blockquote [author[, source]] [link] [source_link_title] %}
    content
    {% endblockquote %}
  • 例子

    1
    2
    3
    {% blockquote @DevDocs https://twitter.com/devdocs/status/356095192085962752 %}
    NEW: DevDocs now comes with syntax highlighting. http://devdocs.io
    {% endblockquote %}
  • 效果

    NEW: DevDocs now comes with syntax highlighting. http://devdocs.io

Code Block

  • 语法

    1
    2
    3
    {% codeblock [title] [lang:language] [url] [link text] [additional options] %}
    code snippet
    {% endcodeblock %}
  • 例子

    1
    2
    3
    4
    {% codeblock _.compact http://underscorejs.org/#compact Underscore.js %}
    _.compact([0, 1, false, 2, '', 3]);
    => [1, 2, 3]
    {% endcodeblock %}
  • 效果

    _.compactUnderscore.js
    1
    2
    _.compact([0, 1, false, 2, '', 3]);
    => [1, 2, 3]

iframe

  • 语法

    1
    {% iframe url [width] [height] %}
  • 例子

    1
    {% iframe /tags 400 300 %}
  • 效果

Include Code

  • 语法

    1
    2
    {% include_code [title] [lang:language] [from:line] [to:line] path/to/file %}
    <!-- 基于`code_dir`路径 -->
  • 例子

    1
    {% include_code lang:javascript from:1 to:16 test.js %}
  • 效果

    test.jsview raw
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    // 冒泡排序
    const bubbleSort = (arr) => {
    let len = arr.length;
    for (let i = 0; i < len; i++) {
    for (let j = 0; j < len - 1 - i; j++) {
    if (arr[j] > arr[j + 1]) {
    let temp = arr[j];
    arr[j] = arr[j + 1];
    arr[j + 1] = temp;
    }
    }
    }
    return arr;
    }

    // 选择排序

Raw

  • 语法

    1
    2
    3
    {% raw %}
    content
    {% endraw %}
  • 例子

    1
    2
    3
    4
    5
    {% raw %}
    {% raw %}
    content
    {% endraw %}
    {% endraw %}
  • 效果

    {% raw %} conten {% endraw %}