Skip to content
Permalink
Browse files

Add support for custom toc header.

  • Loading branch information...
JixunMoe committed May 16, 2017
1 parent 7cf8ee4 commit 636426b253e7dfc363c90ee1fe2f2f2a97cbad30
Showing with 14 additions and 4 deletions.
  1. +2 −0 Config.md
  2. +10 −3 src/js/app/ghost.toc.js
  3. +2 −1 src/js/init.js
@@ -19,6 +19,8 @@
| `toc-name` | 章节目录 ToC 的标题文字 | `Contents` |
| `def-cover-image` | 没有提供文章头图时,自动显示的头图。<br>可使用内置变量。 | `https://example.com/no-image.png?%rand` |
| `font` | 覆盖字体 | `'Microsoft YaHei UI', 'Fallback font 2'` |
| `toc-comments` | 章节目录标题文字 | 章节目录文字 |


---

@@ -27,17 +27,22 @@
return r;
}

function generateLink (html, id) {
var a = $('<a>')
.html(html)
.attr('href', '#' + id);
return $('<li>').append(a);
}

function generateItem (el) {
var $el = $(el);
var a = $('<a>').html($el.html());
var id = $el.attr('id');
if (!id) {
id = uniqueId(strip($el.text()));
$('<span>').attr('id', id).prependTo($el);
}

a[0].href = '#' + id;
return $('<li>').append(a);
return generateLink($el.html(), id);
}

function processLevel (tocs) {
@@ -67,7 +72,9 @@
} while (i < headings.length);
return tocs;
}

var tocRoot = processLevel($('<ul>'));
tocRoot.append(generateLink(config.tocComments, 'isso-thread'));

root
.prepend(
@@ -17,7 +17,8 @@
};

var _default = {
tocName: 'Contents'
tocName: 'Contents',
tocComments: 'Comments'
};

$.j = {

0 comments on commit 636426b

Please sign in to comment.
You can’t perform that action at this time.