mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-24 20:33:00 +00:00
#414, Move commit and edit links to separate pertials to allow overwrites
This commit is contained in:
parent
a424a062ca
commit
3f56e60b6d
@ -1,6 +1,6 @@
|
||||
[
|
||||
{{- $pages := where .Site.Pages "Kind" "in" (slice "page" "section") -}}
|
||||
{{- $pages = where $pages "Params.booksearchexclude" "!=" true -}}
|
||||
{{- $pages = where $pages "Params.bookSearchExclude" "!=" true -}}
|
||||
{{/* Remove until we know why it does not work, see https://github.com/alex-shpak/hugo-book/issues/528 */}}
|
||||
{{/*- $pages = where $pages "Content" "not in" (slice nil "") -*/}}
|
||||
{{- $pages = where $pages "Content" "!=" "" -}}
|
||||
|
@ -3,8 +3,7 @@
|
||||
{{ if and .GitInfo .Site.Params.BookRepo }}
|
||||
<div>
|
||||
{{- $date := partial "docs/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}}
|
||||
{{- $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">
|
||||
<a class="flex align-center" href="{{ partial "docs/links/commit" . }}" title='{{ i18n "Last modified by" }} {{ .GitInfo.AuthorName }} | {{ $date }}' target="_blank" rel="noopener">
|
||||
<img src="{{ "svg/calendar.svg" | relURL }}" class="book-icon" alt="" />
|
||||
<span>{{ $date }}</span>
|
||||
</a>
|
||||
@ -13,8 +12,7 @@
|
||||
|
||||
{{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
|
||||
<div>
|
||||
{{- $bookFilePath := (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename | path.Join) -}}
|
||||
<a class="flex align-center" href="{{ .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}{{ ($bookFilePath) }}" target="_blank" rel="noopener">
|
||||
<a class="flex align-center" href="{{ partial "docs/links/edit" . }}" target="_blank" rel="noopener">
|
||||
<img src="{{ "svg/edit.svg" | relURL }}" class="book-icon" alt="" />
|
||||
<span>{{ i18n "Edit this page" }}</span>
|
||||
</a>
|
||||
|
2
layouts/partials/docs/links/commit.html
Normal file
2
layouts/partials/docs/links/commit.html
Normal file
@ -0,0 +1,2 @@
|
||||
{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}}
|
||||
{{- .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash -}}
|
2
layouts/partials/docs/links/edit.html
Normal file
2
layouts/partials/docs/links/edit.html
Normal file
@ -0,0 +1,2 @@
|
||||
{{- $bookFilePath := (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename | path.Join) -}}
|
||||
{{- .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}{{ ($bookFilePath) -}}
|
@ -9,7 +9,7 @@
|
||||
|
||||
{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
|
||||
<ul>
|
||||
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
|
||||
{{ range (where .Section.Pages "Params.bookHidden" "ne" true) }}
|
||||
{{ if .IsSection }}
|
||||
<li {{- if .Params.BookFlatSection }} class="book-section-flat" {{ end -}}>
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
|
Loading…
Reference in New Issue
Block a user