mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Don't do anything if there's no #toc
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
window.onload = function() {
|
||||
var container = document.querySelector('#toc');
|
||||
|
||||
var toc = initTOC({
|
||||
selector: 'h2, h3',
|
||||
scope: '.post',
|
||||
overwrite: false,
|
||||
prefix: 'toc'
|
||||
});
|
||||
if (container != null) {
|
||||
var toc = initTOC({
|
||||
selector: 'h2, h3',
|
||||
scope: '.post',
|
||||
overwrite: false,
|
||||
prefix: 'toc'
|
||||
});
|
||||
|
||||
var heading = document.createElement("H2");
|
||||
var heading_text = document.createTextNode("Table of Contents");
|
||||
heading.appendChild(heading_text);
|
||||
var heading = document.createElement("H2");
|
||||
var heading_text = document.createTextNode("Table of Contents");
|
||||
heading.appendChild(heading_text);
|
||||
|
||||
container.appendChild(heading);
|
||||
container.appendChild(toc);
|
||||
container.appendChild(heading);
|
||||
container.appendChild(toc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user