perf: calculate heading font size dynamically (#983)

This commit is contained in:
Cotes Chung 2023-05-13 09:03:13 +08:00
parent b3c4d741b2
commit 52f5ee9cd3
No known key found for this signature in database
GPG key ID: 0D9E54843167A808
3 changed files with 19 additions and 34 deletions

View file

@ -86,7 +86,7 @@
<a href="{{ post.url | relative_url }}" class="card post-preview h-100"> <a href="{{ post.url | relative_url }}" class="card post-preview h-100">
<div class="card-body"> <div class="card-body">
{% include datetime.html date=post.date class="small" lang=include.lang %} {% include datetime.html date=post.date class="small" lang=include.lang %}
<h3 class="pt-0 my-2" data-toc-skip>{{ post.title }}</h3> <h4 class="pt-0 my-2" data-toc-skip>{{ post.title }}</h4>
<div class="text-muted small"> <div class="text-muted small">
<p> <p>
{% include no-linenos.html content=post.content %} {% include no-linenos.html content=post.content %}

View file

@ -39,42 +39,27 @@ body {
/* --- Typography --- */ /* --- Typography --- */
h1 { @for $i from 1 through 5 {
@extend %heading; h#{$i} {
@extend %heading;
font-size: 1.9rem; @if $i > 1 {
} @extend %section;
@extend %anchor;
}
h2 { @if $i < 5 {
@extend %heading; $factor: 0.18rem;
@extend %section;
@extend %anchor;
font-size: 1.5rem; @if $i == 1 {
} $factor: 0.23rem;
}
h3 { font-size: 1rem + (5 - $i) * $factor;
@extend %heading; } @else {
@extend %section; font-size: 1rem;
@extend %anchor; }
}
font-size: 1.2rem;
}
h4 {
@extend %heading;
@extend %section;
@extend %anchor;
font-size: 1.15rem;
}
h5 {
@extend %heading;
@extend %section;
@extend %anchor;
font-size: 1.1rem;
} }
a { a {

View file

@ -348,7 +348,7 @@ h1 + .post-meta {
} }
.card { .card {
h3 { h4 {
@extend %text-color; @extend %text-color;
@extend %text-clip; @extend %text-clip;
} }