Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including assemble-plugin-toc with all npm packages installed. Try it out:

require("assemble/package.json"); // assemble is a peer dependency. var assemblePluginToc = require("assemble-plugin-toc")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

assemble-plugin-toc v0.0.4

Assemble目录自动生成插件,生成html使用Cheerio.js.

assemble-plugin-toc NPM version Build Status 依赖模块状态

Assemble目录自动生成插件,生成html使用Cheerio.js.

Table of Contents

Quickstart

包安装:

npm install assemble-plugin-toc --save

Gruntfile.js定制:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    assemble: {
      options: {
        plugins: ['assemble-plugin-toc']
      },
      ...
    }
  });
  grunt.loadNpmTasks('assemble');
  grunt.registerTask('default', ['assemble']);
};

Options

tocid

Type: String
Default: toc

增加html容器id,默认toc

listid

Type: String

定义列表id,默认toc-list

listclass

Type: String

定义列表的类,默认空

hclassprefix

Type: String Default: toc-h

新生成列表标题class前缀,默认toc-h,然后toc-h1,toc-h2,toc-h3

hnameprefix

Type: String Default: toc-name

描点name的前缀,默认toc-name,然后toc-name1,toc-name2,toc-name3

boxid

Type: String

要提取生成toc的容器id,默认是全局

Usage Examples

基本用法

最基本用法:

assemble: {
  blog: {
    options: {
      plugins: ['assemble-plugin-toc'],
    },
    files: {
      './blog/': ['./templates/blog/*.hbs']
    }
  }
}

高级

assemble: {
  blog: {
    options: {
      plugins: ['assemble-plugin-toc'],
      toc: {
        boxid: 'toc'
        listid: 'toc-list'
        listclass: 'listclass'
        hclassprefix: 'toc-h'
        hnameprefix: 'toc-name'
      }
    },
    files: {
      './blog/': ['./templates/blog/*.hbs']
    }
  }
}

注意:要查看链接图标,一定要在服务器状态!

Author

GoldCome

  • Github: https://github.com/GoldCome
  • Blog:http://www.gdcome.com
  • QQ/Email: 363359243@qq.com

Release History

  • 2014-02-21   v0.0.0   重新构建目录生成插件
  • 2014-02-21   v0.0.1   修正当标题存在其他html代码时无法正确获取属性问题
  • 2014-02-22   v0.0.2   增加一个能提取指定id容器内容为toc的选项,并不总是全局,但默认是全局
  • 2014-03-09   v0.0.3   发布到github
  • 2014-03-13   v0.0.4   重新命名发布

License

Copyright (c) 2014 goldcome, contributors. Released under the MIT license


This file was generated on Saturday, March 15, 2014.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free