Jacky Zhao
2022-04-30 b8a660e208333ea8ef4998c2f815411f12ce7067
feat: copyable header anchors (fixes #86)
2 files modified
17 ■■■■■ changed files
assets/styles/base.scss 13 ●●●●● patch | view | raw | blame | history
layouts/partials/textprocessing.html 4 ●●●● patch | view | raw | blame | history
assets/styles/base.scss
@@ -12,6 +12,19 @@
  font-weight: revert;
  margin: revert;
  padding: revert;
  &:hover > .hanchor {
    opacity: 1;
  }
}
.hanchor {
  font-family: Inter;
  margin-left: -1em;
  opacity: 0.3;
  transition: opacity 0.3s ease;
  color: var(--secondary);
}
p, ul, text {
layouts/partials/textprocessing.html
@@ -53,4 +53,8 @@
    {{end}}
  {{end}}
{{end}}
{{/* Add copyable anchors */}}
{{ $content = $content | replaceRE "(<h[1-9] id=\"([^\"]+)\">)(.+)(</h[1-9]>)" `<a href="#${2}">${1}<span class="hanchor" ariaLabel="Anchor"># </span>${3}${4}</a>` }}
{{ $content | safeHTML }}