From ba38e17b1b8140ae9254c1edc6c67ffdc50eca09 Mon Sep 17 00:00:00 2001 From: Collin Brooks Date: Sun, 11 Apr 2021 10:50:54 -0500 Subject: Add custom commit path for last edited link (#319) - A new `BookCommitPath` paramter was added that allows the 'commit' portion of the link to a page's last edited commit hash to be specified. - This is useful when github is not the default repository for a project. Co-authored-by: Collin Brooks --- README.md | 7 +++++++ exampleSite/config.toml | 7 +++++++ exampleSite/config.yaml | 7 +++++++ layouts/partials/docs/footer.html | 3 ++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 25df99d..052730c 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,13 @@ disableKinds = ['taxonomy', 'taxonomyTerm'] # Set source repository location. # Used for 'Last Modified' and 'Edit this page' links. BookRepo = 'https://github.com/alex-shpak/hugo-book' + + # Specifies commit portion of the link to the page's last modified commit hash for 'doc' page + # type. + # Required if 'BookRepo' param is set. + # Value used to construct a URL consisting of BookRepo/BookCommitPath/ + # Github uses 'commit', Bitbucket uses 'commits' + BookCommitPath = 'commit' # Enable 'Edit this page' links for 'doc' page type. # Disabled by default. Uncomment to enable. Requires 'BookRepo' param. diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 025d382..7de852d 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -75,6 +75,13 @@ enableGitInfo = true # Used for 'Last Modified' and 'Edit this page' links. BookRepo = 'https://github.com/alex-shpak/hugo-book' + # (Optional, default 'commit') Specifies commit portion of the link to the page's last modified + # commit hash for 'doc' page type. + # Requires 'BookRepo' param. + # Value used to construct a URL consisting of BookRepo/BookCommitPath/ + # Github uses 'commit', Bitbucket uses 'commits' + # BookCommitPath = 'commit' + # Enable "Edit this page" links for 'doc' page type. # Disabled by default. Uncomment to enable. Requires 'BookRepo' param. # Edit path must point to root directory of repo. diff --git a/exampleSite/config.yaml b/exampleSite/config.yaml index 3c552ce..0d47f6a 100644 --- a/exampleSite/config.yaml +++ b/exampleSite/config.yaml @@ -71,6 +71,13 @@ params: # Used for 'Last Modified' and 'Edit this page' links. BookRepo: https://github.com/alex-shpak/hugo-book + # (Optional, default 'commit') Specifies commit portion of the link to the page's last modified + # commit hash for 'doc' page type. + # Requires 'BookRepo' param. + # Value used to construct a URL consisting of BookRepo/BookCommitPath/ + # Github uses 'commit', Bitbucket uses 'commits' + # BookCommitPath: commit + # Enable "Edit this page" links for 'doc' page type. # Disabled by default. Uncomment to enable. Requires 'BookRepo' param. # Edit path must point to root directory of repo. diff --git a/layouts/partials/docs/footer.html b/layouts/partials/docs/footer.html index f38e679..7f1a08a 100644 --- a/layouts/partials/docs/footer.html +++ b/layouts/partials/docs/footer.html @@ -6,7 +6,8 @@ {{ if and .GitInfo .Site.Params.BookRepo }}
{{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}} - + {{- $commitPath := default "commit" .Site.Params.BookCommitPath -}} + Calendar {{ $date }} -- cgit v1.2.3