From 9a69ea655d96aa8441a3650387fbec7f3f06bc0b Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Sun, 17 Mar 2024 03:25:39 +0100 Subject: [PATCH] feat: use mdbook-last-changed to indicate when a file has been last updated --- .env | 1 + .github/workflows/install-mdbook/action.yml | 9 ++++++++- book.toml | 9 ++++++++- styles/last-changed.css | 7 +++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 styles/last-changed.css diff --git a/.env b/.env index a2b75bbb..193c72da 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ MDBOOK_VERSION=0.4.37 MDBOOK_I18N_HELPERS_VERSION=0.3.2 MDBOOK_PANDOC_VERSION=0.6.0 +MDBOOK_LAST_CHANGED_VERSION=0.1.4 diff --git a/.github/workflows/install-mdbook/action.yml b/.github/workflows/install-mdbook/action.yml index 500f5b68..6cc6d3bf 100644 --- a/.github/workflows/install-mdbook/action.yml +++ b/.github/workflows/install-mdbook/action.yml @@ -26,10 +26,17 @@ runs: echo "version=$MDBOOK_PANDOC_VERSION" >> $GITHUB_OUTPUT shell: bash + - name: Read mdbook-last-changed version from .env + id: mdbook-last-changed-version + run: | + . ./.env + echo "version=$MDBOOK_LAST_CHANGED_VERSION" >> $GITHUB_OUTPUT + shell: bash + - name: Install dependencies uses: taiki-e/install-action@v2 with: - tool: mdbook@${{ steps.mdbook-version.outputs.version }},mdbook-pandoc@${{ steps.mdbook-pandoc-version.outputs.version }},mdbook-i18n-helpers@${{ steps.mdbook-i18n-helpers-version.outputs.version }} + tool: mdbook@${{ steps.mdbook-version.outputs.version }},mdbook-pandoc@${{ steps.mdbook-pandoc-version.outputs.version }},mdbook-i18n-helpers@${{ steps.mdbook-i18n-helpers-version.outputs.version }},mdbook-last-changed@${{ steps.mdbook-last-changed-version.outputs.version }} - name: Install mdbook-pandoc and related dependencies run: | diff --git a/book.toml b/book.toml index 34fb1e76..a44e064b 100644 --- a/book.toml +++ b/book.toml @@ -23,7 +23,14 @@ site-url = "/patterns/" git-repository-url = "https://github.com/rust-unofficial/patterns" git-repository-icon = "fa-github" edit-url-template = "https://github.com/rust-unofficial/patterns/edit/main/{path}" -additional-css = ["theme/css/language-picker.css"] +additional-css = [ + "./theme/css/language-picker.css", + "./styles/last-changed.css", +] + +[preprocessor.last-changed] +command = "mdbook-last-changed" +renderer = ["html"] [output.html.fold] enable = true diff --git a/styles/last-changed.css b/styles/last-changed.css new file mode 100644 index 00000000..21de8212 --- /dev/null +++ b/styles/last-changed.css @@ -0,0 +1,7 @@ +footer { + font-size: 0.8em; + text-align: center; + border-top: 1px solid grey; + padding: 1.25em 0; + margin-top: 1.25em; +}