Skip to content

Commit

Permalink
🐛 Fix: fix h1-h6 tags anchor style
Browse files Browse the repository at this point in the history
  • Loading branch information
bambooom committed Feb 5, 2024
1 parent 4ae8b19 commit 512ec1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions themes/PaperMod/assets/css/common/post-single.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@
font-family: ui-serif,Georgia,Cambria,Times New Roman,Times,serif;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
position: relative;
}

.post-content .anchor {
position: absolute;
left: -30px;
}

.post-content h3,
.post-content h4,
.post-content h5,
Expand Down Expand Up @@ -386,9 +400,7 @@ h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
display: inline-flex;
color: var(--secondary);
margin-inline-start: 8px;
font-weight: 500;
color: var(--purple);
user-select: none;
}

Expand Down
2 changes: 1 addition & 1 deletion themes/PaperMod/assets/css/core/theme-vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
--primary: rgb(30, 30, 30);
--secondary: rgb(108, 108, 108);
--tertiary: rgb(214, 214, 214);
--hilite: rgb(51 51 51);
--hilite: rgb(21 21 21);
--content: rgb(31, 31, 31);
--code-block-bg: rgb(28, 29, 33);
--code-bg: rgb(245, 245, 245);
Expand Down
2 changes: 1 addition & 1 deletion themes/PaperMod/layouts/partials/anchored_headings.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{{- /* formats .Content headings by adding an anchor */ -}}
{{ . | replaceRE "(<h[1-6] id=\"([^\"]+)\".+)(</h[1-6]+>)" "${1}<a hidden class=\"anchor\" aria-hidden=\"true\" href=\"#${2}\">#</a>${3}" | safeHTML }}
{{ . | replaceRE "(<h[1-6] id=\"([^\"]+)\"[^>]*>)([^<]*)(</h[1-6]+>)" "${1}<a hidden class=\"anchor\" aria-hidden=\"true\" href=\"#${2}\">#</a>${3}${4}" | safeHTML }}

0 comments on commit 512ec1c

Please sign in to comment.