mirror of
https://github.com/danpros/htmly.git
synced 2026-04-20 20:46:26 +05:30
Fix Doks toc
This commit is contained in:
parent
95f981bcad
commit
d9edbe55f8
2 changed files with 6 additions and 6 deletions
|
|
@ -25,15 +25,15 @@
|
||||||
* insert the anchor inside the heading
|
* insert the anchor inside the heading
|
||||||
* fix browser not scrolling to the hash
|
* fix browser not scrolling to the hash
|
||||||
*/
|
*/
|
||||||
function htmlTableOfContents (documentRef) {
|
function htmlTableOfContents (id) {
|
||||||
var documentRef = documentRef || document;
|
var documentRef = document;
|
||||||
var toc = documentRef.getElementById('toc');
|
var toc = documentRef.getElementById('toc');
|
||||||
var headings = [].slice.call(documentRef.body.querySelectorAll('#content h1, #content h2, #content h3, #content h4, #content h5, #content h6'));
|
var headings = [].slice.call(documentRef.body.querySelectorAll('#content h1, #content h2, #content h3, #content h4, #content h5, #content h6'));
|
||||||
headings.forEach(function (heading, index) {
|
headings.forEach(function (heading, index) {
|
||||||
heading.setAttribute('id', 'toc-' + heading.textContent.replace(/\s+/g, '-').toLowerCase());
|
heading.setAttribute('id', heading.textContent.replace(/\s+/g, '-').toLowerCase() + id);
|
||||||
|
|
||||||
var link = documentRef.createElement('a');
|
var link = documentRef.createElement('a');
|
||||||
link.setAttribute('href', '#toc-' + heading.textContent.replace(/\s+/g, '-').toLowerCase());
|
link.setAttribute('href', '#' + heading.textContent.replace(/\s+/g, '-').toLowerCase() + id);
|
||||||
link.textContent = heading.textContent;
|
link.textContent = heading.textContent;
|
||||||
|
|
||||||
var div = documentRef.createElement('div');
|
var div = documentRef.createElement('div');
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<link rel="stylesheet" href="<?php echo theme_path();?>css/style.css">
|
<link rel="stylesheet" href="<?php echo theme_path();?>css/style.css">
|
||||||
<meta name="theme-color" content="#fff">
|
<meta name="theme-color" content="#fff">
|
||||||
</head>
|
</head>
|
||||||
<body class="docs single" onload="htmlTableOfContents();">
|
<body class="docs single" <?php if (isset($is_page)):?>onload="htmlTableOfContents('.page-<?php echo $static->slug;?>');"<?php endif;?> <?php if (isset($is_subpage)):?>onload="htmlTableOfContents('.subpage-<?php echo $static->slug;?>');"<?php endif;?>>
|
||||||
<div class="header-bar fixed-top"></div>
|
<div class="header-bar fixed-top"></div>
|
||||||
<?php if (facebook()) { echo facebook(); } ?>
|
<?php if (facebook()) { echo facebook(); } ?>
|
||||||
<?php if (login()) { toolbar(); } ?>
|
<?php if (login()) { toolbar(); } ?>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue