Make it compatible with Hugo 0.55 (#13680)
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.
This commit is contained in:
parent
2d1fdb0666
commit
b51bdc88cc
|
@ -48,7 +48,7 @@
|
||||||
{{ $logo := .Resources.GetMatch "**logo*.png" }}
|
{{ $logo := .Resources.GetMatch "**logo*.png" }}
|
||||||
{{ $p := . }}
|
{{ $p := . }}
|
||||||
<a target="_blank" href="{{ with $p.Params.content_url }}{{ . | safeURL }}{{ else }}{{ .RelPermalink }}{{ end }}">{{ with $logo }}<img src="{{ .RelPermalink }}" alt="{{ $p.LinkTitle }}">{{ else }}
|
<a target="_blank" href="{{ with $p.Params.content_url }}{{ . | safeURL }}{{ else }}{{ .RelPermalink }}{{ end }}">{{ with $logo }}<img src="{{ .RelPermalink }}" alt="{{ $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 }}</a>
|
{{ end }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a target="_blank" href="https://docs.google.com/a/google.com/forms/d/e/1FAIpQLScuI7Ye3VQHQTwBASrgkjQDSS5TP0g3AXfFhwSM9YpHgxRKFA/viewform" class="tell-your-story"><img src="/images/case_studies/story.png" alt="Tell your story"></a>
|
<a target="_blank" href="https://docs.google.com/a/google.com/forms/d/e/1FAIpQLScuI7Ye3VQHQTwBASrgkjQDSS5TP0g3AXfFhwSM9YpHgxRKFA/viewform" class="tell-your-story"><img src="/images/case_studies/story.png" alt="Tell your story"></a>
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
{{ define "content" }}
|
{{ 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" $ ) }}
|
{{ partial "docs/content-page" (dict "ctx" $ "page" $ ) }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ if ge (len .Pages) 1 }}
|
{{ if ge (len .Pages) 1 }}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{{ $menuSections := (where $docs.Sections ".Params.main_menu" true) }}
|
{{ $menuSections := (where $docs.Sections ".Params.main_menu" true) }}
|
||||||
{{ range $menuSections }}
|
{{ range $menuSections }}
|
||||||
{{ if $p.IsDescendant . }}
|
{{ if $p.IsDescendant . }}
|
||||||
<h1>{{ if not (strings.Contains .Dir "home")}}{{ .Params.bigheader | default .Title }}{{ end }}</h1>
|
<h1>{{ if not (strings.Contains .Path "home")}}{{ .Params.bigheader | default .Title }}{{ end }}</h1>
|
||||||
<h5>{{ .Params.abstract }}</h5>
|
<h5>{{ .Params.abstract }}</h5>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if not .Params.noedit }}
|
{{ if not .Params.noedit }}
|
||||||
<a href="https://github.com/kubernetes/website/edit/master/content/{{ site.Language.Lang }}/{{ .File.Path }}" class="button issue">{{ T "main_edit_this_page" }}</a>
|
{{ if .File }}<a href="https://github.com/kubernetes/website/edit/master/content/{{ site.Language.Lang }}/{{ .File.Path }}" class="button issue">{{ T "main_edit_this_page" }}</a>{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
{{ if and (not .Params.showcommit) $.GitInfo }}
|
{{ if and (not .Params.showcommit) $.GitInfo }}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{{ .ctx.Scratch.Set "sections" slice }}
|
{{ .ctx.Scratch.Set "sections" slice }}
|
||||||
<ul id="markdown-toc">
|
<ul id="markdown-toc">
|
||||||
{{ range .ctx.Scratch.Get "blocks" }}
|
{{ range .ctx.Scratch.Get "blocks" }}
|
||||||
{{ if .content }}
|
{{ if .block }}
|
||||||
{{ $.ctx.Scratch.Set "section" .content }}
|
|
||||||
{{ else}}
|
|
||||||
{{ $.ctx.Scratch.Set "section" (partial "templates/block" .) }}
|
{{ $.ctx.Scratch.Set "section" (partial "templates/block" .) }}
|
||||||
|
{{ else}}
|
||||||
|
{{ $.ctx.Scratch.Set "section" .content }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $section := $.ctx.Scratch.Get "section" }}
|
{{ $section := $.ctx.Scratch.Get "section" }}
|
||||||
{{ $headers := findRE "<h2.*?>(.|\n)*?</h2>" $section }}
|
{{ $headers := findRE "<h2.*?>(.|\n)*?</h2>" $section }}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{{ $_hugo_config := `{ "version": 1 }`}}
|
||||||
{{- $id := .Get 0 -}}
|
{{- $id := .Get 0 -}}
|
||||||
{{- if not $id -}}
|
{{- if not $id -}}
|
||||||
{{- errorf "missing id in capture" -}}
|
{{- errorf "missing id in capture" -}}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
{{ $file := .Get "file" }}
|
{{ $file := .Get "file" }}
|
||||||
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
|
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
|
||||||
{{ $fileDir := path.Split $file }}
|
{{ $fileDir := path.Split $file }}
|
||||||
{{ $bundlePath := path.Join .Page.Dir $fileDir.Dir }}
|
{{ $bundlePath := path.Join .Page.File.Dir $fileDir.Dir }}
|
||||||
{{ $filename := path.Join $p.Dir $file }}
|
{{ $filename := path.Join $p.File.Dir $file }}
|
||||||
{{ $ghlink := printf "https://%s/blob/master/content/%s/%s" site.Params.githubwebsiterepo .Page.Lang $filename | safeURL }}
|
{{ $ghlink := printf "https://%s/blob/master/content/%s/%s" site.Params.githubwebsiterepo .Page.Lang $filename | safeURL }}
|
||||||
{{/* First assume this is a bundle and the file is inside it. */}}
|
{{/* First assume this is a bundle and the file is inside it. */}}
|
||||||
{{ $resource := $p.Resources.GetMatch (printf "%s*" $file ) }}
|
{{ $resource := $p.Resources.GetMatch (printf "%s*" $file ) }}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{{ $file := .Get "file" }}
|
{{ $file := .Get "file" }}
|
||||||
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
|
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
|
||||||
{{ $fileDir := path.Split $file }}
|
{{ $fileDir := path.Split $file }}
|
||||||
{{ $bundlePath := path.Join .Page.Dir $fileDir.Dir }}
|
{{ $bundlePath := path.Join .Page.File.Dir $fileDir.Dir }}
|
||||||
{{ $filename := printf "/content/%s/examples/%s" .Page.Lang $file | safeURL }}
|
{{ $filename := printf "/content/%s/examples/%s" .Page.Lang $file | safeURL }}
|
||||||
{{ $ghlink := printf "https://%s/master%s" site.Params.githubwebsiteraw $filename | safeURL }}
|
{{ $ghlink := printf "https://%s/master%s" site.Params.githubwebsiteraw $filename | safeURL }}
|
||||||
{{/* First assume this is a bundle and the file is inside it. */}}
|
{{/* First assume this is a bundle and the file is inside it. */}}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
{{- .Content | safeHTML -}}
|
{{- .Content | safeHTML -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{/* It is not a resource in the includes bundle. Try to find the page relative to the current. */}}
|
{{/* It is not a resource in the includes bundle. Try to find the page relative to the current. */}}
|
||||||
{{- $path := path.Join $.Page.Dir $name -}}
|
{{- $path := path.Join $.Page.File.Dir $name -}}
|
||||||
{{- $page := site.GetPage "page" $path -}}
|
{{- $page := site.GetPage "page" $path -}}
|
||||||
{{- with $page }}
|
{{- with $page }}
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else}}
|
{{ else}}
|
||||||
{{ $path := path.Join $.Page.Dir .include }}
|
{{ $path := path.Join $.Page.File.Dir .include }}
|
||||||
{{ $page := site.GetPage "page" $path }}
|
{{ $page := site.GetPage "page" $path }}
|
||||||
{{ with $page }}
|
{{ with $page }}
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
|
Loading…
Reference in New Issue