Last active
January 16, 2025 14:24
-
-
Save penyt/ded9d1f55c1f10673a35ea4e00117394 to your computer and use it in GitHub Desktop.
hugo toc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <section class="article-content"> | |
| {{ partial "article/components/toc-inline" . }} <!--我放在這裡--> | |
| {{ $wrappedTable := printf "<div class=\"table-wrapper\">${1}</div>" }} | |
| <!--以下省略--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //在小螢幕上顯示內文toc | |
| @media (max-width: 1024px) { | |
| .toc--inline { | |
| display: block; | |
| } | |
| } | |
| //在大螢幕上隱藏內文toc | |
| @media (min-width: 1024px) { | |
| .toc--inline { | |
| display: none; | |
| } | |
| } | |
| //內文toc樣式 | |
| .toc--inline { | |
| background-color: var(--card-background); | |
| 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); | |
| ol { | |
| list-style-type: none; | |
| counter-reset: item; | |
| li a:first-of-type::before { | |
| counter-increment: item; | |
| content: counters(item, ".") ". "; | |
| font-weight: bold; | |
| margin-right: 5px; | |
| } | |
| } | |
| } | |
| .toc--title { | |
| text-align: center; | |
| font-size: 24px; | |
| font-weight: bold; | |
| margin-bottom: 0; | |
| } | |
| .toc--desc { | |
| text-align: center; | |
| margin-top: 0; | |
| color: rgba(185, 183, 183, 0.5) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!--內文toc--> | |
| {{ if (.Scratch.Get "TOCEnabled") }} | |
| <section class="toc toc--inline"> | |
| <p class="toc--title">{{ T "article.tableOfContents" }}</p> | |
| <p class="toc--desc"> inline table of content only on mobile</p> | |
| <div class=""> | |
| {{ .TableOfContents }} | |
| </div> | |
| </section> | |
| {{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment