From b8a660e208333ea8ef4998c2f815411f12ce7067 Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Sat, 30 Apr 2022 13:10:12 -0700 Subject: [PATCH] feat: copyable header anchors (fixes #86) --- assets/styles/base.scss | 13 +++++++++++++ layouts/partials/textprocessing.html | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/assets/styles/base.scss b/assets/styles/base.scss index 4d03a06..3b2801b 100644 --- a/assets/styles/base.scss +++ b/assets/styles/base.scss @@ -12,6 +12,19 @@ h1, h2, h3, h4, h5, h6, ol, ul, thead { 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 { diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html index 2312aa4..8e8c999 100644 --- a/layouts/partials/textprocessing.html +++ b/layouts/partials/textprocessing.html @@ -53,4 +53,8 @@ {{end}} {{end}} {{end}} + +{{/* Add copyable anchors */}} +{{ $content = $content | replaceRE "()(.+)()" `${1}# ${3}${4}` }} + {{ $content | safeHTML }}