anchored-headings: port to PaperMod

- add corresponding css
- gen anchored headings for h1-h6
- link with single.html
This commit is contained in:
Aditya Telange 2020-11-10 12:15:56 +05:30
parent 2b0619f684
commit cf4fd27e3d
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77
3 changed files with 16 additions and 2 deletions

View File

@ -315,6 +315,18 @@
transform: scale(0.96);
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
display: inline-flex;
color: var(--secondary);
margin-inline-start: 8px;
font-weight: 500;
}
@media screen and (max-width: 600px) {
.post-content blockquote {
margin: 0 calc(var(--gap) * -1);

View File

@ -41,7 +41,9 @@
</details>
</div>
{{- end }}
<div class="post-content">{{ .Content }}</div>
<div class="post-content">
{{- partial "anchored_headings.html" .Content -}}
</div>
<footer class="post-footer">
{{- if .Params.tags }}
<ul class="post-tags">

View File

@ -1,2 +1,2 @@
<!-- formats .Content headings by adding an anchor -->
{{ . | replaceRE "(<h[2-3] id=\"([^\"]+)\".+)(</h[2-9]+>)" "${1}<a class=\"anchor\" 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}" | safeHTML }}