Skip to content

Commit

Permalink
Add before and after partials for toc (alex-shpak#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods authored Jan 26, 2021
1 parent a12baf0 commit 012ccee
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ hugo server --minify --theme book

### File tree menu (default)

By default, the theme will render pages from the `content/docs` section as a menu in a tree structure.
By default, the theme will render pages from the `content/docs` section as a menu in a tree structure.
You can set `title` and `weight` in the front matter of pages to adjust the order and titles in the menu.

### Leaf bundle menu

You can also use leaf bundle and the content of its `index.md` file as menu.
You can also use leaf bundle and the content of its `index.md` file as menu.
Given you have the following file structure:

```
Expand Down Expand Up @@ -108,14 +108,14 @@ And Enable it by setting `BookMenuBundle: /menu` in Site configuration.

## Blog

A simple blog is supported in the section `posts`.
A simple blog is supported in the section `posts`.
A blog is not the primary usecase of this theme, so it has only minimal features.

## Configuration

### Site Configuration

There are a few configuration options that you can add to your `config.toml` file.
There are a few configuration options that you can add to your `config.toml` file.
You can also see the `yaml` example [here](https://github.com/alex-shpak/hugo-book/blob/master/exampleSite/config.yaml).

```toml
Expand Down Expand Up @@ -234,15 +234,17 @@ bookSearchExclude = true

There are few empty partials you can override in `layouts/partials/`

| Partial | Placement |
| -------------------------------------------------- | -------------------------------------- |
| `layouts/partials/docs/inject/head.html` | Before closing `<head>` tag |
| `layouts/partials/docs/inject/body.html` | Before closing `<body>` tag |
| `layouts/partials/docs/inject/footer.html` | After page footer content |
| `layouts/partials/docs/inject/menu-before.html` | At the beginning of `<nav>` menu block |
| `layouts/partials/docs/inject/menu-after.html` | At the end of `<nav>` menu block |
| `layouts/partials/docs/inject/content-before.html` | Before page content |
| `layouts/partials/docs/inject/content-after.html` | After page content |
| Partial | Placement |
| -------------------------------------------------- | ------------------------------------------- |
| `layouts/partials/docs/inject/head.html` | Before closing `<head>` tag |
| `layouts/partials/docs/inject/body.html` | Before closing `<body>` tag |
| `layouts/partials/docs/inject/footer.html` | After page footer content |
| `layouts/partials/docs/inject/menu-before.html` | At the beginning of `<nav>` menu block |
| `layouts/partials/docs/inject/menu-after.html` | At the end of `<nav>` menu block |
| `layouts/partials/docs/inject/content-before.html` | Before page content |
| `layouts/partials/docs/inject/content-after.html` | After page content |
| `layouts/partials/docs/inject/toc-before.html` | At the beginning of table of contents block |
| `layouts/partials/docs/inject/toc-after.html` | At the end of table of contents block |

### Extra Customisation

Expand Down Expand Up @@ -300,7 +302,7 @@ If you want lower maintenance, use one of the released versions. If you want to

### [Extra credits to contributors](https://github.com/alex-shpak/hugo-book/graphs/contributors)

Contributions are welcome and I will review and consider pull requests.
Contributions are welcome and I will review and consider pull requests.
Primary goals are:

- Keep it simple.
Expand Down
4 changes: 2 additions & 2 deletions assets/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ ul.pagination {
flex: 0 0 $toc-width;
font-size: $font-size-12;

nav {
> nav {
width: $toc-width;
padding: $padding-16;

Expand Down Expand Up @@ -377,7 +377,7 @@ aside nav,
@media screen and (min-width: $container-max-width) {
.book-page,
.book-menu nav,
.book-toc nav {
.book-toc > nav {
padding: $padding-16 * 2 $padding-16;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Target":"book.min.134b70e5316650a530cb42e4e8630b2a01d532bebfc0337028211175336e4806.css","MediaType":"text/css","Data":{"Integrity":"sha256-E0tw5TFmUKUwy0Lk6GMLKgHVMr6/wDNwKCERdTNuSAY="}}
{"Target":"book.min.5284606b3d4d63899357ff95f4032c205e62b86963d9241c255c46093296e5a0.css","MediaType":"text/css","Data":{"Integrity":"sha256-UoRgaz1NY4mTV/+V9AMsIF5iuGlj2SQcJVxGCTKW5aA="}}
6 changes: 5 additions & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@

{{ if default true (default .Site.Params.BookToC .Params.BookToC) }}
<aside class="book-toc">
{{ template "toc" . }} <!-- Table of Contents -->
<nav>
{{ partial "docs/inject/toc-before" . }}
{{ template "toc" . }} <!-- Table of Contents -->
{{ partial "docs/inject/toc-after" . }}
</nav>
</aside>
{{ end }}
</main>
Expand Down
Empty file.
Empty file.

0 comments on commit 012ccee

Please sign in to comment.