Go to file
Jan-Erik Rediger 9660612724 Make the error message more useful when no git root can be found
Fixes #4
2023-04-11 13:14:26 +02:00
.github/workflows No check, just test 2022-12-18 18:54:50 +01:00
book Add book for testing 2022-11-01 18:53:51 +01:00
src Make the error message more useful when no git root can be found 2023-04-11 13:14:26 +02:00
.gitignore Add book for testing 2022-11-01 18:53:51 +01:00
Cargo.lock chore: Release mdbook-last-changed version 0.1.2 2022-12-18 18:56:11 +01:00
Cargo.toml chore: Release mdbook-last-changed version 0.1.2 2022-12-18 18:56:11 +01:00
LICENSE Working preprocessor to add a footer 2022-10-18 21:11:00 +02:00
README.md Add book for testing 2022-11-01 18:53:51 +01:00

README.md

mdbook-last-changed

A preprocessor for mdbook to add a page's last change date and a link to the commit on every page.

It adds a "Last change" footer, including a date and a link to the corresponding commit. It uses the configured git-repository-url as the base.

Requirements

  • The git command line tool.
  • A configured git repository url in your book.toml configuration. See Configuration.
  • Access to the git repository checkout while building your book.

Installation

If you want to use only this preprocessor, install the tool:

cargo install mdbook-last-changed

Add it as a preprocessor to your book.toml:

[preprocessor.last-changed]
command = "mdbook-last-changed"
renderer = ["html"]

Configuration

mdbook-last-changed is configured using additional options under [output.html]:

[output.html]
# Required: Your repository URL used in the link.
git-repository-url = "https://github.com/$user/$project"

To style the footer add a custom CSS file for your HTML output:

[output.html]
additional-css = ["last-changed.css"]

And in last-changed.css style the <footer> element or directly the CSS element id last-changed:

footer {
  font-size: 0.8em;
  text-align: center;
  border-top: 1px solid black;
  padding: 5px 0;
}

This code block shrinks the text size, center-aligns it under the rest of the content and adds a small horizontal bar above the text to separate it from the page content.

Finally, build your book as normal:

mdbook path/to/book

License

MPL. See LICENSE.
Copyright (c) 2022 Jan-Erik Rediger janerik@fnordig.de