New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

katelog

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

katelog

a pure javascript tool to generate html catelog by head (h1, h2, h3, h4, h5, h6);

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

文章目录自动生成器

类似于segmentfault和掘金的文章目录,无第三方依赖的,自动生成文章目录结构,灵活配置

demo地址

npm引入

npm i katelog -S

es6使用

import katelog from 'katelog';
console.log(katelog);

html引入

<!-- 引入js文件 -->
<script src='./katelog.min.js'></script>
<!-- 文章容器 -->
<div id="kCatelog"></div>
<!-- 目录容器 -->
<div class="k-catelog-list" id="catelogList"></div>
new katelog({
    contentEl: 'kCatelog',
    catelogEl: 'catelogList',
    linkClass: 'k-catelog-link',
    linkActiveClass: 'k-catelog-link-active',
    supplyTop: 20,
    selector: ['h2', 'h3'],
    active: function (el) {
        console.log(el);
    }
});

仅支持IE8以上和主流的浏览器

选项

contentEl

文章容器,id选择器

catelogEl

目录容器,id选择器

linkClass

每个目录项的类

linkActiveClass

当前激活的目录项的类

selector(可选)

选择目录的标题元素,默认支持6级树形结构

默认值: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']

selector: ['h2', 'h3']
supplyTop(可选)

每个目录需要补充的高度,比如fixed头部布局会挡住实现,可以设置supplyTop来修正

方法

rebuild()

动态新增或者删除的内容,重新构建目录

let katelog = new katelog({ ... });
katelog.rebuild();

Keywords

catelog

FAQs

Package last updated on 25 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts