Skip to content

Commit

Permalink
fix: hide toc when a single heading
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Jan 4, 2024
1 parent 6ba3f7a commit a78c2c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
theme
theme/*
!theme/pagetoc-tweaks.css
book
3 changes: 2 additions & 1 deletion docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ src = "src"
title = "devshell"

[preprocessor.pagetoc]

[output.html]
# Show github links in top bar
git-repository-url = "https://github.com/numtide/devshell"
edit-url-template = "https://github.com/numtide/devshell/edit/main/docs/{path}"
additional-css = ["theme/pagetoc.css"]
additional-css = ["theme/pagetoc.css", "theme/pagetoc-tweaks.css"]
additional-js = ["theme/pagetoc.js"]
1 change: 1 addition & 0 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ stdenv.mkDerivation {
fileset = fs.unions [
(fs.fileFilter (file: file.hasExt "md") ./.)
./book.toml
./theme/pagetoc-tweaks.css
];
};

Expand Down
5 changes: 5 additions & 0 deletions docs/theme/pagetoc-tweaks.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Adapted from https://github.com/slowsage/mdbook-pagetoc */

a[class^="pagetoc-H"]:only-child {
display: none;
}

0 comments on commit a78c2c9

Please sign in to comment.