From 462506cb92d68e42fe9de5659c080e8087255eda Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Mon, 29 Apr 2024 17:04:44 +0800 Subject: [PATCH] :lipstick: Style: refactor heading style --- assets/css/_page/_single.scss | 69 +++++++++----------- layouts/_default/_markup/render-heading.html | 14 ++-- 2 files changed, 37 insertions(+), 46 deletions(-) diff --git a/assets/css/_page/_single.scss b/assets/css/_page/_single.scss index 3664e4b7..c73556df 100644 --- a/assets/css/_page/_single.scss +++ b/assets/css/_page/_single.scss @@ -97,68 +97,61 @@ .content { > h1, > h2 { - font-size: 1.5rem; - - & code { - font-size: 1.25rem; - } + font-size: 1.5em; + padding-bottom: 0.3em; + border-bottom: 1px solid $global-border-color; } > h3 { - font-size: 1.375rem; - - & code { - font-size: 1.125rem; - } + font-size: 1.25em; } > h4 { - font-size: 1.25rem; - - & code { - font-size: 1rem; - } + font-size: 1em; } > h5 { - font-size: 1.125rem; + font-size: 0.875em; } > h6 { - font-size: 1rem; + font-size: 0.85em; } - h2, - h3, - h4, - h5, - h6 { + > .heading-element { + display: flex; font-weight: bold; - margin: 1.2rem 0; + line-height: 1.25; + margin-top: 1.5rem; + margin-bottom: 1rem; [data-theme='dark'] & { font-weight: bolder; } - } - > h2, - > h3, - > h4, - > h5, - > h6 { - > .heading-mark::before { - content: '|'; - margin-right: 0.3125rem; - color: $single-link-color; + code { + padding: 0 .2em; + font-size: inherit; + } - [data-theme='dark'] & { - color: $single-link-color-dark; + &:hover { + > .heading-mark { + opacity: 1; } } - } - > h2 > .heading-mark::before { - content: '#'; + > .heading-mark { + display: inline-flex; + align-items: center; + opacity: 0; + padding-inline: 0.5rem; + transition: all 0.2s ease-in-out; + @include link(false, false); + + svg { + fill: currentColor; + } + } } p { diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index 26d0a4a4..e40df06a 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -13,9 +13,7 @@ {{- end -}} - - - + {{- $title := .Text -}} {{- /* Only enable in main section pages */ -}} {{- $onlyMainSection := cond $params.heading.number.onlyMainSection (eq .Page.Type "posts") true -}} {{- if $params.heading.number.enable | and $onlyMainSection -}} @@ -33,7 +31,7 @@ {{- $h6 := "6" | index $headingMap | int | string -}} {{- /* Apply the level based on the format */ -}} - {{- $title := "" -}} + {{- $title = "" -}} {{- if .Level | eq 1 -}} {{- $title = $h1Format -}} {{- else if .Level | eq 2 -}} @@ -55,10 +53,10 @@ {{- $title = replace $title "{h5}" $h5 -}} {{- $title = replace $title "{h6}" $h6 -}} {{- $title = replace $title "{title}" .Text -}} - {{- $title | safeHTML -}} - - {{- else -}} - {{- .Text | safeHTML -}} {{- end -}} + {{ $title | safeHTML }} + + + {{- /* EOF */ -}}