diff --git a/assets/css/src/texts.css b/assets/css/src/texts.css index ba9dd6c..6047752 100644 --- a/assets/css/src/texts.css +++ b/assets/css/src/texts.css @@ -29,7 +29,8 @@ h5, h5 *, p, p *:not(strong), -figcaption { +figcaption, +.toc{ font-weight: var(--font-weight-light); line-height: 1; } diff --git a/assets/css/src/toc.css b/assets/css/src/toc.css new file mode 100644 index 0000000..9239140 --- /dev/null +++ b/assets/css/src/toc.css @@ -0,0 +1,15 @@ + +.page-cover .toc{ + position: fixed; + display: block; + width: calc(var(--body-padding) - var(--unit--horizontal) * 2) ; + left: 0; + top: 15vw; + padding-inline: var(--unit--horizontal); +} +.toc_label{ + font-size: var(--font-size-m); +} +.toc li{ + margin-left: 0; +} \ No newline at end of file diff --git a/assets/css/style.css b/assets/css/style.css index b2f743a..f415d15 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -12,6 +12,7 @@ @import url("src/footer.css"); @import url("src/toggle-light-mode.css"); @import url("src/print.css"); +@import url("src/toc.css"); diff --git a/site/plugins/helpers/index.php b/site/plugins/helpers/index.php index 3a4d755..8726f56 100644 --- a/site/plugins/helpers/index.php +++ b/site/plugins/helpers/index.php @@ -12,6 +12,14 @@ function allYears ($article) { return $years; } +function addAnchors($content) { + $content = preg_replace_callback('/

(.*?)<\/h3>/', function($matches) { + $slug = Str::slug($matches[1]); + return '

' . $matches[1] . '

'; + }, $content); + return $content; +} + function setTitleFontSizeClass($title, $level = 'h1') { $length = strlen($title); diff --git a/site/snippets/cover.php b/site/snippets/cover.php index 01db5c4..1b2f77a 100644 --- a/site/snippets/cover.php +++ b/site/snippets/cover.php @@ -8,6 +8,9 @@ $isOpen ??= false; title() ?> + parent()->parent()->is('textes')){ + snippet('toc', ["content" => $page->bodyBlocks()->toBlocks()]); + } ?> text()): ?>
text() ?> diff --git a/site/snippets/toc.php b/site/snippets/toc.php new file mode 100644 index 0000000..24226ad --- /dev/null +++ b/site/snippets/toc.php @@ -0,0 +1,13 @@ + + diff --git a/site/templates/linear.php b/site/templates/linear.php index 9177510..c58cd5c 100644 --- a/site/templates/linear.php +++ b/site/templates/linear.php @@ -24,6 +24,7 @@ +
chapo()->isNotEmpty()): ?>
@@ -33,7 +34,7 @@ isHtmlMode()->isTrue()): ?> htmlBody()->kt() ?> bodyBlocks()->isNotEmpty()): ?> - bodyBlocks()->toBlocks() ?> + bodyBlocks()->toBlocks()) ?> body() ?>