Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
fix(toc): fix toc link bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonzq committed Feb 21, 2020
1 parent 41a14bc commit a4116f1
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 177 deletions.
1 change: 1 addition & 0 deletions assets/css/_core/_base.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
html {
font-family: $global-font-family;
font-size: 16px;
width:100%;
}

/* scrollbar, only support webkit */
Expand Down
13 changes: 5 additions & 8 deletions assets/css/_core/_media.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
.page {
max-width: 780px;

.post-toc {
width: 300px;
#toc-auto {
margin-left: 800px;
}
}
Expand All @@ -13,8 +12,7 @@
.page {
max-width: 680px;

.post-toc {
width: 240px;
#toc-auto {
margin-left: 700px;
}
}
Expand All @@ -24,8 +22,7 @@
.page {
max-width: 560px;

.post-toc {
width: 180px;
#toc-auto {
margin-left: 580px;
}
}
Expand All @@ -41,11 +38,11 @@
.page {
max-width: 80%;

.post-toc {
#toc-auto {
display: none;
}

.post-toc-mobile {
#toc-static {
display: block;
}
}
Expand Down
16 changes: 8 additions & 8 deletions assets/css/_partial/_single/_toc.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
.post-toc {
#toc-auto {
display: block;
position: absolute;
width: 360px;
width: 100%;
margin-left: 1000px;
padding: 0 .8rem;
border-left: 1px solid $global-border-color;
overflow-wrap: break-word;
box-sizing: border-box;
top: $post-toc-top;
top: if($header-normal-mode-desktop, 7rem, 12rem);

.dark-theme & {
border-left: 1px solid $global-border-color-dark;
}

.post-toc-title {
.toc-title {
font-weight: 400;
margin: .8rem 0;
text-transform: uppercase;
}

.post-toc-content {
.toc-content {
&.always-active ul {
display: block;
}
Expand Down Expand Up @@ -73,13 +73,13 @@
}
}

.post-toc-mobile {
#toc-static {
display: none;
padding-top: .8rem;

details {
summary {
.post-toc-title {
.toc-title {
display: block;
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -110,7 +110,7 @@
}
}

.post-toc-content {
.toc-content {
border: 2px solid $code-background-color;

>nav>ul {
Expand Down
3 changes: 0 additions & 3 deletions assets/css/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ $header-position-mobile: if($header-normal-mode-mobile, static, fixed) !default;
$page-padding-top-desktop: if($header-normal-mode-desktop, 1rem, 6rem) !default;
$page-padding-top-mobile: if($header-normal-mode-mobile, 1rem, 6rem) !default;

// Top of the post toc
$post-toc-top: if($header-normal-mode-desktop, 7rem, 12rem) !default;

// Color of the hover header item
$header-hover-color: #161209 !default;
$header-hover-color-dark: #fff !default;
Expand Down
2 changes: 1 addition & 1 deletion exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ themesDir = "../.."
pre = '<i class="fas fa-language fa-fw"></i>'
name = ""
title = "简体中文"
url = "zh"
url = "/zh/"
weight = 5
[languages.en.params]
# LoveIt theme version
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{{- .Site.Title -}}
</a>
</div>
<div class="menu-toggle" id="menu-toggle">
<div class="menu-toggle" id="menu-toggle-mobile">
<span></span><span></span><span></span>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion layouts/partials/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
{{- $key }}: {{ $var | safeJS -}},
{{- end -}}
};
window.echartsArr = [];
</script>
{{- end -}}
{{- end -}}
Expand Down
22 changes: 9 additions & 13 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,24 @@ <h1 class="single-title animated flipInX">{{ .Title }}</h1>

{{- /* TOC */ -}}
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<aside class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ T "toc" }}</h2>
<div class="toc-auto" id="toc-auto">
<h2 class="toc-title">{{ T "toc" }}</h2>
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
<div class="post-toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}">
{{- .TableOfContents -}}
</div>
</aside>
<aside class="post-toc-mobile" id="post-toc-mobile">
<div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div>
</div>
<div class="toc-static" id="toc-static">
<details>
<summary>
<div class="post-toc-title">
<div class="toc-title">
<span>{{ T "toc" }}</span>
<span><i class="details icon fas fa-angle-down"></i></span>
</div>
</summary>
<div class="post-toc-content">
{{- $toc := .TableOfContents -}}
{{- $toc = replaceRE `id="TableOfContents"` `id="TableOfContentsMobile"` $toc -}}
{{- $toc | safeHTML -}}
<div class="toc-content" id="toc-content-static">
{{- .TableOfContents -}}
</div>
</details>
</aside>
</div>
{{- end -}}

{{- /* Content */ -}}
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit a4116f1

Please sign in to comment.