diff --git a/config.toml b/config.toml index b5bff353..5090c687 100644 --- a/config.toml +++ b/config.toml @@ -19,7 +19,6 @@ theme = "toggle" # light, dark, auto, toggle comment = false fancy_code = true dynamic_note = true # a note that can be toggled -h_anchor_link = true # mathjax = true # mathjax_dollar_inline_enable = true diff --git a/content/posts/_index.md b/content/posts/_index.md index 1018bf32..895d95d2 100644 --- a/content/posts/_index.md +++ b/content/posts/_index.md @@ -2,4 +2,6 @@ paginate_by = 7 title = "Posts" sort_by = "date" + +insert_anchor_links = "heading" +++ diff --git a/content/posts/configuration.md b/content/posts/configuration.md index c8312467..a4d7983c 100644 --- a/content/posts/configuration.md +++ b/content/posts/configuration.md @@ -8,6 +8,13 @@ tags=["blog"] # Configuration +## Anchor Links + +You can add anchor links by adding the following to your `_index.md`: +```toml +insert_anchor_links = "heading" +``` + ## Table of Contents (`toc`) Enables or disables the table of contents for posts. @@ -79,16 +86,6 @@ Allows for the creation of togglable note sections in your content. When enabled, you can create expandable/collapsible note sections in your blog posts. -## Header Anchor Links (`h_anchor_link`) - -Adds anchor links to headers for easy referencing. - -- Type: Boolean -- Default: true -- Usage: `h_anchor_link = true` - -This feature adds clickable links next to headers, allowing readers to easily share or bookmark specific sections of your posts. - ## Menu Defines the navigation menu items for your blog. diff --git a/sass/parts/_misc.scss b/sass/parts/_misc.scss index bac4046b..c7739ab2 100644 --- a/sass/parts/_misc.scss +++ b/sass/parts/_misc.scss @@ -49,6 +49,10 @@ a { z-index: 1; } +a.zola-anchor { + border-bottom: none; +} + a:hover { background-color: var(--primary-color); color: var(--hover-color); @@ -72,8 +76,8 @@ time { // change the line-through color del { - text-decoration-color: var(--primary-color); - text-decoration-thickness: 3px; + text-decoration-color: var(--primary-color); + text-decoration-thickness: 3px; } @media all and (max-width: 640px) { @@ -120,7 +124,9 @@ del { } } -.MathJax_Display, .MJXc-display, .MathJax_SVG_Display { - overflow-x: auto; - overflow-y: hidden; -} +.MathJax_Display, +.MJXc-display, +.MathJax_SVG_Display { + overflow-x: auto; + overflow-y: hidden; +} \ No newline at end of file diff --git a/static/js/anchor.js b/static/js/anchor.js deleted file mode 100644 index 89dffe2b..00000000 --- a/static/js/anchor.js +++ /dev/null @@ -1,26 +0,0 @@ -document.addEventListener('DOMContentLoaded', function () { - const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); - const idCounts = {}; // Object to keep track of IDs and their occurrences - - headings.forEach((heading) => { - if (!heading.classList.contains('linked')) { - let baseId = heading.textContent.toLowerCase().replace(/\s+/g, '-').replace(/[^\w\-]+/g, ''); - let id = baseId; - - // Check if the ID already exists, and if so, append a number to make it unique - if (idCounts[baseId]) { - id = `${baseId}-${idCounts[baseId]}`; - idCounts[baseId] += 1; - } else { - idCounts[baseId] = 1; - } - - heading.id = id; // Assign unique ID based on heading text - - // Wrap the text in an anchor tag and mark the heading - heading.innerHTML = `${heading.innerHTML}`; - heading.classList.add('linked'); // Mark the heading to avoid re-processing - } - }); -}); - diff --git a/templates/partials/header.html b/templates/partials/header.html index b0028326..92fc995e 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -116,12 +116,7 @@ {% if config.extra.toc | default(value=false) %} {% endif %} - - {# H_tag anchor links#} - {% if config.extra.h_anchor_link | default(value=false) %} - - {% endif %} - + {# Dynamic Note #} {% if config.extra.dynamic_note | default(value=false) %}