Refactor language file structure and improve article content selection logic in toc.js
This commit is contained in:
1 parent
0225e8ff6a
commit
a33b949942
2 files changed
+5
-7
No files matched your search
+2
-4
@@ -1,6 +1,4 @@
|
||||
{
|
||||
"plugin-bludit-toc": {
|
||||
"name": "Table of Contents",
|
||||
"description": "Sticky ToC sidebar (desktop) and floating drawer (mobile) generated from the article's h2/h3/h4 headings."
|
||||
}
|
||||
"plugin-name": "Table of Contents",
|
||||
"plugin-description": "Sticky ToC sidebar (desktop) and floating drawer (mobile) generated from the article's h2/h3/h4 headings."
|
||||
}
|
||||
@@ -18,12 +18,12 @@
|
||||
document.head.appendChild(styleEl);
|
||||
|
||||
/* ---- Find the article content area ---- */
|
||||
/* Only match unambiguous single-article containers to avoid firing on
|
||||
homepage post-list cards that also contain <article> and <h2> tags. */
|
||||
var content = document.querySelector('.content')
|
||||
|| document.querySelector('article .entry-content')
|
||||
|| document.querySelector('.entry-content')
|
||||
|| document.querySelector('.post-content')
|
||||
|| document.querySelector('article')
|
||||
|| document.querySelector('main');
|
||||
|| document.querySelector('.post-content');
|
||||
|
||||
if (!content) return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user