mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-25 04:43:04 +00:00
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 <cbrooks@sentryds.com>
This commit is contained in:
parent
e2786374ad
commit
ba38e17b1b
@ -163,6 +163,13 @@ disableKinds = ['taxonomy', 'taxonomyTerm']
|
|||||||
# Set source repository location.
|
# Set source repository location.
|
||||||
# Used for 'Last Modified' and 'Edit this page' links.
|
# Used for 'Last Modified' and 'Edit this page' links.
|
||||||
BookRepo = 'https://github.com/alex-shpak/hugo-book'
|
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/<commit-hash>
|
||||||
|
# Github uses 'commit', Bitbucket uses 'commits'
|
||||||
|
BookCommitPath = 'commit'
|
||||||
|
|
||||||
# Enable 'Edit this page' links for 'doc' page type.
|
# Enable 'Edit this page' links for 'doc' page type.
|
||||||
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
|
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
|
||||||
|
@ -75,6 +75,13 @@ enableGitInfo = true
|
|||||||
# Used for 'Last Modified' and 'Edit this page' links.
|
# Used for 'Last Modified' and 'Edit this page' links.
|
||||||
BookRepo = 'https://github.com/alex-shpak/hugo-book'
|
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/<commit-hash>
|
||||||
|
# Github uses 'commit', Bitbucket uses 'commits'
|
||||||
|
# BookCommitPath = 'commit'
|
||||||
|
|
||||||
# Enable "Edit this page" links for 'doc' page type.
|
# Enable "Edit this page" links for 'doc' page type.
|
||||||
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
|
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
|
||||||
# Edit path must point to root directory of repo.
|
# Edit path must point to root directory of repo.
|
||||||
|
@ -71,6 +71,13 @@ params:
|
|||||||
# Used for 'Last Modified' and 'Edit this page' links.
|
# Used for 'Last Modified' and 'Edit this page' links.
|
||||||
BookRepo: https://github.com/alex-shpak/hugo-book
|
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/<commit-hash>
|
||||||
|
# Github uses 'commit', Bitbucket uses 'commits'
|
||||||
|
# BookCommitPath: commit
|
||||||
|
|
||||||
# Enable "Edit this page" links for 'doc' page type.
|
# Enable "Edit this page" links for 'doc' page type.
|
||||||
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
|
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
|
||||||
# Edit path must point to root directory of repo.
|
# Edit path must point to root directory of repo.
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
{{ if and .GitInfo .Site.Params.BookRepo }}
|
{{ if and .GitInfo .Site.Params.BookRepo }}
|
||||||
<div>
|
<div>
|
||||||
{{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}}
|
{{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}}
|
||||||
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/commit/{{ .GitInfo.Hash }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
|
{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}}
|
||||||
|
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
|
||||||
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="Calendar" />
|
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="Calendar" />
|
||||||
<span>{{ $date }}</span>
|
<span>{{ $date }}</span>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user