Update post.php
This commit is contained in:
parent
21c75cdde2
commit
f8fc4f293a
7
post.php
7
post.php
|
@ -208,18 +208,15 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
}
|
}
|
||||||
currentLevel--;
|
currentLevel--;
|
||||||
}
|
}
|
||||||
|
const numbers = levelCounts.slice(1, level + 1).join(' ') ;
|
||||||
// 生成序号并在末尾添加点
|
|
||||||
const numbers = levelCounts.slice(1, level + 1).join(' ') + '.';
|
|
||||||
const item = document.createElement('li');
|
const item = document.createElement('li');
|
||||||
item.classList.add('toc-item'); // 添加基本类
|
item.classList.add('toc-item'); // 添加基本类
|
||||||
item.classList.add(`level-${level}`); // 根据级别添加类
|
item.classList.add(`level-${level}`); // 根据级别添加类
|
||||||
|
|
||||||
const anchor = `toc${index}`;
|
const anchor = `toc${index}`;
|
||||||
head.id = anchor;
|
head.id = anchor;
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = `#${anchor}`;
|
link.href = `#${anchor}`;
|
||||||
link.textContent = `${numbers} ${head.textContent}`; // 序号+标题文本
|
link.textContent = `${numbers}. ${head.textContent}`; // 序号+标题文本
|
||||||
item.appendChild(link);
|
item.appendChild(link);
|
||||||
currentList.appendChild(item);
|
currentList.appendChild(item);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue