Skip to content

Commit

Permalink
#414, Move commit and edit links to separate pertials to allow overwr…
Browse files Browse the repository at this point in the history
…ites
  • Loading branch information
alex-shpak committed Oct 2, 2024
1 parent a424a06 commit 3f56e60
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/search-data.json
Original file line number Diff line number Diff line change
@@ -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" "!=" "" -}}
Expand Down
6 changes: 2 additions & 4 deletions layouts/partials/docs/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions layouts/partials/docs/links/commit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}}
{{- .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash -}}
2 changes: 2 additions & 0 deletions layouts/partials/docs/links/edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{- $bookFilePath := (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename | path.Join) -}}
{{- .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}{{ ($bookFilePath) -}}
2 changes: 1 addition & 1 deletion layouts/partials/docs/menu-filetree.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down

0 comments on commit 3f56e60

Please sign in to comment.