mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-04-29 03:53:30 +08:00
First idea to add inline toc
This commit is contained in:
parent
0a5cbea10f
commit
9fb507a6ff
@ -10,7 +10,7 @@
|
||||
max-width: var(--right-sidebar-max-width);
|
||||
|
||||
/// Display right sidebar when min-width: lg
|
||||
@include respond(lg) {
|
||||
@include respond(xl) {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
@ -373,6 +373,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.toc--inline {
|
||||
background-color: rgb(241, 241, 241);
|
||||
margin-left: calc((var(--card-padding)) * -1);
|
||||
margin-right: calc((var(--card-padding)) * -1);
|
||||
padding-left: var(--card-padding);
|
||||
padding-right: var(--card-padding);
|
||||
|
||||
padding-top: var(--card-padding);
|
||||
padding-bottom: var(--card-padding);
|
||||
|
||||
@include respond(xl) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/// Negative margins
|
||||
blockquote,
|
||||
figure,
|
||||
|
@ -1,4 +1,6 @@
|
||||
<section class="article-content">
|
||||
{{ partial "article/components/toc-inline" . }}
|
||||
|
||||
<!-- Refer to https://discourse.gohugo.io/t/responsive-tables-in-markdown/10639/5 -->
|
||||
{{ $wrappedTable := printf "<div class=\"table-wrapper\">${1}</div>" }}
|
||||
{{ .Content | replaceRE "(<table>(?:.|\n)+?</table>)" $wrappedTable | safeHTML }}
|
||||
|
9
layouts/partials/article/components/toc-inline.html
Normal file
9
layouts/partials/article/components/toc-inline.html
Normal file
@ -0,0 +1,9 @@
|
||||
{{ if (.Scratch.Get "TOCEnabled") }}
|
||||
<section class="toc toc--inline">
|
||||
<h2 class="">{{ T "article.tableOfContents" }}</h2>
|
||||
<div class="" >
|
||||
{{ .TableOfContents }}
|
||||
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
Loading…
Reference in New Issue
Block a user