From 3f56e60b6d862c262bafd3a133a3e5eac83832f0 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Wed, 2 Oct 2024 23:16:25 +0200 Subject: [PATCH] #414, Move commit and edit links to separate pertials to allow overwrites --- assets/search-data.json | 2 +- layouts/partials/docs/footer.html | 6 ++---- layouts/partials/docs/links/commit.html | 2 ++ layouts/partials/docs/links/edit.html | 2 ++ layouts/partials/docs/menu-filetree.html | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/docs/links/commit.html create mode 100644 layouts/partials/docs/links/edit.html diff --git a/assets/search-data.json b/assets/search-data.json index 0348cbe10..0a65bf06f 100644 --- a/assets/search-data.json +++ b/assets/search-data.json @@ -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" "!=" "" -}} diff --git a/layouts/partials/docs/footer.html b/layouts/partials/docs/footer.html index 607f2aa3e..77e96d803 100644 --- a/layouts/partials/docs/footer.html +++ b/layouts/partials/docs/footer.html @@ -3,8 +3,7 @@ {{ 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 -}} - + {{ $date }} @@ -13,8 +12,7 @@ {{ if and .File .Site.Params.BookRepo .Site.Params.BookEditPath }}
- {{- $bookFilePath := (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename | path.Join) -}} - + {{ i18n "Edit this page" }} diff --git a/layouts/partials/docs/links/commit.html b/layouts/partials/docs/links/commit.html new file mode 100644 index 000000000..8ab9334f2 --- /dev/null +++ b/layouts/partials/docs/links/commit.html @@ -0,0 +1,2 @@ +{{- $commitPath := default "commit" .Site.Params.BookCommitPath -}} +{{- .Site.Params.BookRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash -}} \ No newline at end of file diff --git a/layouts/partials/docs/links/edit.html b/layouts/partials/docs/links/edit.html new file mode 100644 index 000000000..920affa00 --- /dev/null +++ b/layouts/partials/docs/links/edit.html @@ -0,0 +1,2 @@ +{{- $bookFilePath := (strings.TrimPrefix hugo.WorkingDir .Page.File.Filename | path.Join) -}} +{{- .Site.Params.BookRepo }}/{{ .Site.Params.BookEditPath }}{{ ($bookFilePath) -}} \ No newline at end of file diff --git a/layouts/partials/docs/menu-filetree.html b/layouts/partials/docs/menu-filetree.html index edb150c5f..149458884 100644 --- a/layouts/partials/docs/menu-filetree.html +++ b/layouts/partials/docs/menu-filetree.html @@ -9,7 +9,7 @@ {{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
    - {{ range (where .Section.Pages "Params.bookhidden" "ne" true) }} + {{ range (where .Section.Pages "Params.bookHidden" "ne" true) }} {{ if .IsSection }}
  • {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}