From b51bdc88ccd5a0146e81b61d1873ad3f8d876478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 9 Apr 2019 03:19:05 +0200 Subject: [PATCH] Make it compatible with Hugo 0.55 (#13680) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds two backwards compatible changes to prepare for the next Hugo version, most notable: * All the `File` methods on `Page` has been deprecated and will give a warning in the next Hugo version. Adjust this by changing `.Dir` to ยด.File.Dir` and similar. * Version the capture shortcode to use the old behaviour for markdown rendering of shortcode inner content. --- layouts/case-studies/list.html | 2 +- layouts/docs/list.html | 8 +++++++- layouts/partials/docs/top-menu.html | 2 +- layouts/partials/git-info.html | 2 +- layouts/partials/templates/blocks.html | 6 +++--- layouts/shortcodes/capture.html | 1 + layouts/shortcodes/code.html | 4 ++-- layouts/shortcodes/codenew.html | 2 +- layouts/shortcodes/include.html | 2 +- layouts/shortcodes/tabs.html | 2 +- 10 files changed, 19 insertions(+), 12 deletions(-) diff --git a/layouts/case-studies/list.html b/layouts/case-studies/list.html index 7998cf5c0b..6d554f8a09 100644 --- a/layouts/case-studies/list.html +++ b/layouts/case-studies/list.html @@ -48,7 +48,7 @@ {{ $logo := .Resources.GetMatch "**logo*.png" }} {{ $p := . }} {{ with $logo }}{{ $p.LinkTitle }}{{ else }} - {{ errorf "Case Studies: Missing logo for %s. Put a PNG with the word 'logo' in the filename into %q" $p.LinkTitle $p.Dir }} + {{ errorf "Case Studies: Missing logo for %s. Put a PNG with the word 'logo' in the filename into %q" $p.LinkTitle $p.File.Dir }} {{ end }} {{ end }} Tell your story diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 5d1101e3dc..cbeaa25094 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -1,5 +1,11 @@ {{ define "content" }} - {{ with .Content }} + {{ $hasContent := false }} + {{ with .File }} + {{ if ne .Filename "" }} + {{ $hasContent = (ge (len $.RawContent) 100) }} + {{ end }} + {{ end }} + {{ if $hasContent }} {{ partial "docs/content-page" (dict "ctx" $ "page" $ ) }} {{ else }} {{ if ge (len .Pages) 1 }} diff --git a/layouts/partials/docs/top-menu.html b/layouts/partials/docs/top-menu.html index 452cf8bec0..25093e9b1a 100644 --- a/layouts/partials/docs/top-menu.html +++ b/layouts/partials/docs/top-menu.html @@ -4,7 +4,7 @@ {{ $menuSections := (where $docs.Sections ".Params.main_menu" true) }} {{ range $menuSections }} {{ if $p.IsDescendant . }} -

{{ if not (strings.Contains .Dir "home")}}{{ .Params.bigheader | default .Title }}{{ end }}

+

{{ if not (strings.Contains .Path "home")}}{{ .Params.bigheader | default .Title }}{{ end }}

{{ .Params.abstract }}
{{ end }} {{ end }} diff --git a/layouts/partials/git-info.html b/layouts/partials/git-info.html index 57baea2178..f285d614f7 100644 --- a/layouts/partials/git-info.html +++ b/layouts/partials/git-info.html @@ -19,7 +19,7 @@ {{ end }} {{ end }} {{ if not .Params.noedit }} - {{ T "main_edit_this_page" }} + {{ if .File }}{{ T "main_edit_this_page" }}{{ end }} {{ end }} {{ if and (not .Params.showcommit) $.GitInfo }} diff --git a/layouts/partials/templates/blocks.html b/layouts/partials/templates/blocks.html index 765b884ac7..2056538510 100644 --- a/layouts/partials/templates/blocks.html +++ b/layouts/partials/templates/blocks.html @@ -1,10 +1,10 @@ {{ .ctx.Scratch.Set "sections" slice }}