Convert site to Hugo (#8316)
This commit converts content and layout to use Hugo.
This commit is contained in:
committed by
k8s-ci-robot
parent
7745f0e0c5
commit
7f3b633aa0
@@ -0,0 +1,6 @@
|
||||
{{- $id := .Get 0 -}}
|
||||
{{- if not $id -}}
|
||||
{{- errorf "missing id in capture" -}}
|
||||
{{- end -}}
|
||||
{{- $capture_id := printf "__cid_%s" $id -}}
|
||||
{{- .Page.Scratch.Set $capture_id .Inner -}}
|
||||
@@ -0,0 +1,3 @@
|
||||
<blockquote class="caution">
|
||||
<div>{{ .Inner | markdownify }}</div>
|
||||
</blockquote>
|
||||
@@ -0,0 +1,38 @@
|
||||
{{ $p := .Page }}
|
||||
{{ $file := .Get "file" }}
|
||||
{{ $codelang := .Get "language" | default (path.Ext $file | strings.TrimPrefix ".") }}
|
||||
{{ $fileDir := path.Split $file }}
|
||||
{{ $bundlePath := path.Join .Page.Dir $fileDir.Dir }}
|
||||
{{ $filename := path.Join $p.Dir $file }}
|
||||
{{ $ghlink := printf "https://%s/blob/master/content/%s/%s" .Page.Site.Params.githubWebsiteRepo .Page.Lang $filename | safeURL }}
|
||||
{{/* First assume this is a bundle and the file is inside it. */}}
|
||||
{{ $resource := $p.Resources.GetMatch (printf "%s*" $file ) }}
|
||||
{{ with $resource }}
|
||||
{{ $.Scratch.Set "content" .Content }}
|
||||
{{ else }}
|
||||
{{/* Read the file relative to the content root. */}}
|
||||
{{ $resource := readFile $filename}}
|
||||
{{ with $resource }}{{ $.Scratch.Set "content" . }}{{ end }}
|
||||
{{ end }}
|
||||
{{ if not ($.Scratch.Get "content") }}
|
||||
{{ errorf "[%s] %q not found in %q" $p.Site.Language.Lang $fileDir.File $bundlePath }}
|
||||
{{ end }}
|
||||
{{ with $.Scratch.Get "content" }}
|
||||
<table class="includecode" id="{{ $file | anchorize }}">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
{{ with $ghlink }}<a href="{{ . }}" download="{{ $file }}">{{ end }}
|
||||
<code>{{ $file }} {{ $bundlePath }}</code>
|
||||
{{ if $ghlink }}</a>{{ end }}
|
||||
<img src="{{ "images/copycode.svg" | relURL }}" style="max-height:24px" onclick="copyCode('{{ $file | anchorize }}')" title="Copy {{ $file }} to clipboard">
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>{{ highlight . $codelang "" }} </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
||||
@@ -0,0 +1 @@
|
||||
{{ if .Inner}}{{ end }}
|
||||
@@ -0,0 +1,12 @@
|
||||
{{ if .Page.Param "deprecated" }}
|
||||
<section id="deprecationWarning">
|
||||
<main>
|
||||
<div class="content deprecation-warning">
|
||||
<h3>
|
||||
Documentation for Kubernetes {{ .Page.Param "version" }} is no longer actively maintained. The version you are currently viewing is a static snapshot.
|
||||
For up-to-date documentation, see the <a href="{{ .Params.currentUrl }}">latest</a> version.
|
||||
</h3>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,10 @@
|
||||
{{ $valid_states := "alpha, beta, deprecated, stable" }}
|
||||
{{ $state := .Get "state" }}
|
||||
{{ $for_k8s_version := .Get "for_k8s_version" }}
|
||||
{{ $width := .Get "width" }}
|
||||
{{ $is_valid := strings.Contains $valid_states $state }}
|
||||
{{ if not $is_valid }}
|
||||
{{ errorf "%q is not a valid feature-state, use one of %q" $valid_states }}
|
||||
{{ else }}
|
||||
{{ partial "templates/feature-state.html" (dict "ctx" . "page" .Page "state" $state "for_k8s_version" $for_k8s_version "width" $width) }}
|
||||
{{ end }}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
{{- $id := .Get "term_id" -}}
|
||||
{{- $length := .Get "length" -}}
|
||||
{{- $prepend := .Get "prepend" }}
|
||||
{{- $glossaryBundle := .Site.GetPage "page" "docs/reference/glossary" -}}
|
||||
{{- $glossaryItems := $glossaryBundle.Resources.ByType "page" -}}
|
||||
{{- $term_info := $glossaryItems.GetMatch (printf "%s*" $id ) -}}
|
||||
{{- if not $term_info -}}
|
||||
{{- errorf "[%s] %q: %q is not a valid glossary term_id, see ./docs/reference/glossary/* for a full list" .Page.Site.Language.Lang .Page.Path $id -}}
|
||||
{{- end -}}
|
||||
{{- with $term_info -}}
|
||||
{{- if (strings.Contains "short" $length) -}}
|
||||
{{- with .Summary -}}
|
||||
{{- if $prepend }}{{- replace . "<p>" (printf "<P>%s %s" $prepend .) -}}{{ else }}{{- . -}}{{ end -}}
|
||||
{{- else -}}
|
||||
{{- partial "templates/errorthrower.html" (dict "block" "summary" "purpose" .purpose "describes the key term in greater depth, supplementing the short-description") . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if (strings.Contains "all|long" $length) -}}
|
||||
{{- with .Content -}}
|
||||
{{- if $prepend }}
|
||||
{{- $firstPara := index (findRE "(?s)<p>.*?</p>" . 1) 0 -}}
|
||||
{{- $firstPara := $firstPara | strings.TrimSuffix "</p>" | strings.TrimPrefix "<p>" -}}
|
||||
{{- $first := slicestr $firstPara 0 1 | lower }}
|
||||
{{- $prepended := printf "<p>%s %s%s</p>" $prepend $first (slicestr $firstPara 1) -}}
|
||||
{{- replace . $firstPara $prepended | safeHTML -}}{{ else }}{{- . -}}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,22 @@
|
||||
{{- $id := .Get "term_id" -}}
|
||||
{{- $text := .Get "text" -}}
|
||||
{{- $glossaryBundle := .Site.GetPage "page" "docs/reference/glossary" -}}
|
||||
{{- $glossaryItems := $glossaryBundle.Resources.ByType "page" -}}
|
||||
{{- $term_info := $glossaryItems.GetMatch (printf "%s*" $id ) -}}
|
||||
{{- if not $term_info -}}
|
||||
{{- errorf "[%s] %q: %q is not a valid glossary term_id, see ./docs/reference/glossary/* for a full list" .Page.Site.Language.Lang .Page.Path $id -}}
|
||||
{{- end }}
|
||||
{{- with $term_info -}}
|
||||
{{- $text := $text | default $term_info.Title -}}
|
||||
{{- $glossary_home := "docs/reference/glossary/?all=true" | relLangURL -}}
|
||||
{{- $external_link := $term_info.Params.full_link | default (printf "%s#term-%s" $glossary_home $id | safeURL ) -}}
|
||||
{{- $tooltip := $term_info.Params.short_description | markdownify -}}
|
||||
{{- $tooltip := $tooltip | replaceRE "(?s)<a class='glossary-tooltip'.*?>(.*?)<span class='tooltip-text'>.*</a>" "$1" | plainify -}}
|
||||
{{- $tooltip := trim $tooltip " \n" -}}
|
||||
<a class='glossary-tooltip' href='{{ $external_link }}' target='_blank'>
|
||||
{{- $text -}}
|
||||
<span class='tooltip-text'>
|
||||
{{- $tooltip | safeHTML -}}
|
||||
</span>
|
||||
</a>
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,27 @@
|
||||
{{/* This will try to find a resource in the "includes" bundle */}}
|
||||
{{- $name := .Get 0 -}}
|
||||
{{- if $name -}}
|
||||
{{- $bundle := $.Site.GetPage "page" "includes" -}}
|
||||
{{- with $bundle -}}
|
||||
{{- $pattern := printf "%s*" $name -}}
|
||||
{{- range $bundle.Resources -}}
|
||||
{{- end -}}
|
||||
{{- $resource := $bundle.Resources.GetMatch $pattern -}}
|
||||
{{- with $resource -}}
|
||||
{{- .Content | safeHTML -}}
|
||||
{{- else -}}
|
||||
{{/* It is not a resource in the includes bundle. Try to find the page relative to the current. */}}
|
||||
{{- $path := path.Join $.Page.Dir $name -}}
|
||||
{{- $page := $.Page.Site.GetPage "page" $path -}}
|
||||
{{- with $page }}
|
||||
{{ .Content }}
|
||||
{{- else -}}
|
||||
{{ errorf "[%s] no Resource or Page matching %q." $.Page.Lang ($pattern | safeHTML ) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{ errorf "[%s] the 'inclucdes' bundle was not found." $.Page.Lang }}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- errorf "[%s] missing resource name in include for page %q" $.Page.Lang $.Page.Path -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,5 @@
|
||||
{{- $text := .Get "text" -}}
|
||||
{{- $url := .Get "url" -}}
|
||||
{{- $target := .Get "target" | default "_blank" -}}
|
||||
{{- $class := .Get "class" -}}
|
||||
<a href="{{ $url }}" target="{{ $target }}"{{ with $class }}class="{{ . }}"{{ end }}>{{ $text }}</a>
|
||||
@@ -0,0 +1,3 @@
|
||||
<blockquote class="note">
|
||||
<div>{{ .Inner | markdownify }}</div>
|
||||
</blockquote>
|
||||
@@ -0,0 +1 @@
|
||||
{{- .Page.Param (.Get 0) -}}
|
||||
@@ -0,0 +1 @@
|
||||
<a href="{{- printf "/docs/reference/generated/kubernetes-api/%s" .Page.Site.Params.latest -}}" target="_blank">API reference docs</a>
|
||||
@@ -0,0 +1,19 @@
|
||||
{{ if .Parent }}
|
||||
{{ $name := trim (.Get "name") " " }}
|
||||
{{ $include := trim (.Get "include") " "}}
|
||||
{{ $codelang := .Get "codelang" }}
|
||||
{{ if not (.Parent.Scratch.Get "tabs") }}
|
||||
{{ .Parent.Scratch.Set "tabs" slice }}
|
||||
{{ end }}
|
||||
{{ with .Inner }}
|
||||
{{ if $codelang }}
|
||||
{{ $.Parent.Scratch.Add "tabs" (dict "name" $name "content" (highlight . $codelang "") ) }}
|
||||
{{ else }}
|
||||
{{ $.Parent.Scratch.Add "tabs" (dict "name" $name "content" . ) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $.Parent.Scratch.Add "tabs" (dict "name" $name "include" $include "codelang" $codelang) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{- errorf "[%s] %q: tab shortcode missing its parent" .Page.Site.Language.Lang .Page.Path -}}
|
||||
{{ end}}
|
||||
@@ -0,0 +1,43 @@
|
||||
{{ .Page.Scratch.Add "tabset-counter" 1 }}
|
||||
{{ $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize }}
|
||||
{{ $tabs := .Scratch.Get "tabs" }}
|
||||
{{ if .Inner }}{{/* We don't use the inner content, but Hugo will complain if we don't reference it. */}}{{ end }}
|
||||
<div id="{{ $tab_set_id }}">
|
||||
<ul>
|
||||
{{ range $i, $e := $tabs }}
|
||||
{{ $id := printf "%s-%d" $tab_set_id $i }}
|
||||
<li><a href="#{{ $id }}">{{ trim .name " " }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ range $i, $e := $tabs }}
|
||||
{{ $id := printf "%s-%d" $tab_set_id $i }}
|
||||
<div id="{{ $id }}">
|
||||
{{ with .content }}
|
||||
{{ . }}
|
||||
{{ else }}
|
||||
{{ if eq $.Page.BundleType "leaf" }}
|
||||
{{/* find the file somewhere inside the bundle. Note the use of double asterisk */}}
|
||||
{{ with $.Page.Resources.GetMatch (printf "**%s*" .include) }}
|
||||
{{ if ne .ResourceType "page" }}
|
||||
{{/* Assume it is a file that needs code highlighting. */}}
|
||||
{{ $codelang := $e.codelang | default ( path.Ext .Name | strings.TrimPrefix ".") }}
|
||||
{{ highlight .Content $codelang "" }}
|
||||
{{ else}}
|
||||
{{ .Content }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else}}
|
||||
{{ $path := path.Join $.Page.Dir .include }}
|
||||
{{ $page := $.Page.Site.GetPage "page" $path }}
|
||||
{{ with $page }}
|
||||
{{ .Content }}
|
||||
{{ else }}
|
||||
{{ errorf "[%s] tabs include not found for path %q" $.Page.Site.Language.Lang $path}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ $elem := $tab_set_id | safeJS }}
|
||||
<script>$(function(){$("#{{ $elem }}").tabs();});</script>
|
||||
@@ -0,0 +1 @@
|
||||
{{ .Page.TableOfContents }}
|
||||
@@ -0,0 +1,6 @@
|
||||
{{ $minVersion := .Page.Param "min-kubernetes-server-version" }}
|
||||
{{ if eq $minVersion (.Page.Param "version") }}
|
||||
Your Kubernetes server must be version {{ $minVersion }}.
|
||||
{{ else if $minVersion}}
|
||||
Your Kubernetes server must be version {{ $minVersion }} or later.
|
||||
{{ end }} To check the version, enter <code>kubectl version</code>.
|
||||
@@ -0,0 +1,9 @@
|
||||
{{ $versions := .Page.Param "versions" }}
|
||||
{{ $thisVersion := .Page.Param "version" }}
|
||||
<ul>
|
||||
{{ range $versions }}
|
||||
{{ if ne .version $thisVersion }}
|
||||
<li><a href="{{ .url }}">{{ .version }}</a></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
@@ -0,0 +1,3 @@
|
||||
<blockquote class="warning">
|
||||
<div>{{ .Inner | markdownify }}</div>
|
||||
</blockquote>
|
||||
Reference in New Issue
Block a user