Skip to content

Commit

Permalink
fix: output the TOC inside post content if the sidebar is disabled (#800
Browse files Browse the repository at this point in the history
)

Fix #798
  • Loading branch information
razonyang committed Nov 17, 2022
1 parent c145476 commit fe449ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/main/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ app.attach(
new TableWrapper(document.querySelectorAll('table')),
new Docs(),
new FormValidator(),
new TOC('#post-toc-container', '#TableOfContents'),
new TOC('#post-toc-container', '.sidebar #TableOfContents'),
new Game(),
...components
);
Expand Down
10 changes: 8 additions & 2 deletions layouts/partials/post/toc-wrapper.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{{- if partial "functions/toc" . -}}
<div id="postTOC" class="mt-2 mb-4 d-block d-xxl-none">
{{ $withoutSidebar := eq .Params.sidebar false }}
<div id="postTOC" class="mt-2 mb-4{{ if not $withoutSidebar }} d-block d-xxl-none{{ end }}">
<h2 class="text-surface mb-3">{{ i18n "table_of_contents" }}</h2>
<div id="post-toc-container"></div>
<div id="post-toc-container">
{{/* Output the TOC if sidebar is disabled. */}}
{{- if $withoutSidebar }}
{{- .TableOfContents -}}
{{ end -}}
</div>
</div>
{{- end -}}

0 comments on commit fe449ea

Please sign in to comment.