|
| 1 | +{{- /* Renders one KEP `seeAlso` entry as a link. Shapes present in keps.json: |
| 2 | + - markdown link: "[Title](https://…)" |
| 3 | + - full URL: "https://…" |
| 4 | + - root-relative path: "/keps/sig-scheduling/624-scheduling-framework" |
| 5 | + - bare repo path: "keps/sig-node/4569-cgroup-v1-maintenance-mode/README.md" |
| 6 | + - nested path: "/keps/prod-readiness/sig-apps/3329" |
| 7 | + - singular "/kep/": "/kep/sig-network/0752-endpointslices/" |
| 8 | + - free text: "KEP-32", "TBD", "n/a" |
| 9 | + |
| 10 | + Every path shape resolves to the referenced KEP's own page on this site, so every |
| 11 | + entry reads the same way regardless of how it was written. Paths we can't resolve |
| 12 | + fall back to GitHub, and anything else is left as text. |
| 13 | + |
| 14 | + @param {string} context One seeAlso entry. |
| 15 | +*/ -}} |
| 16 | +{{- $entry := . -}} |
| 17 | +{{- if strings.Contains $entry "[" -}} |
| 18 | + {{ $entry | markdownify }} |
| 19 | +{{- else if strings.HasPrefix $entry "http" -}} |
| 20 | + <a href="{{ $entry }}" target="_blank" rel="noopener"><i class="fas fa-external-link-alt" aria-hidden="true"></i> {{ $entry }}</a> |
| 21 | +{{- else -}} |
| 22 | + {{- $path := printf "/%s" (strings.TrimPrefix "/" $entry) -}} |
| 23 | + {{- /* A few entries write "/kep/…" for "/keps/…"; normalizing here fixes both the |
| 24 | + lookup below and the directory name the GitHub fallback links to. */ -}} |
| 25 | + {{- $path = replaceRE `^/kep/` "/keps/" $path -}} |
| 26 | + {{- $kep := "" -}} |
| 27 | + {{- /* The SIG is usually the only directory before the number, but some entries nest |
| 28 | + further ("/keps/prod-readiness/sig-apps/3329", kubeadm's own subdirectory). */ -}} |
| 29 | + {{- with findRESubmatch `^/keps/(?:[^/]+/)*([0-9]+)([^/]*)` $path 1 -}} |
| 30 | + {{- $number := index . 0 1 -}} |
| 31 | + {{- $directory := printf "%s%s" $number (index . 0 2) -}} |
| 32 | + {{- $lookup := strings.TrimLeft "0" $number -}} |
| 33 | + {{- with partialCached "keps/page-by-number.html" $lookup $lookup -}} |
| 34 | + {{- /* A zero-padded number is legacy per-directory numbering ("0006-apply.md", |
| 35 | + kubeadm's "0023-kubeadm-config.md") that only coincidentally matches a |
| 36 | + modern KEP number, so require an exact directory match before trusting it. |
| 37 | + Unpadded numbers are global KEP numbers and stay correct even when the |
| 38 | + KEP's directory has since been renamed. */ -}} |
| 39 | + {{- if or (not (strings.HasPrefix $number "0")) (eq .Params.name $directory) -}} |
| 40 | + {{- $kep = . -}} |
| 41 | + {{- end -}} |
| 42 | + {{- end -}} |
| 43 | + {{- end -}} |
| 44 | + {{- if $kep -}} |
| 45 | + <a href="{{ $kep.RelPermalink }}"><i class="fas fa-link" aria-hidden="true"></i> KEP-{{ $kep.Params.kepNumber }}: {{ $kep.Title }}</a> |
| 46 | + {{- else if strings.Contains $path "/keps/" -}} |
| 47 | + <a href="https://github.com/kubernetes/enhancements/tree/master{{ $path }}" target="_blank" rel="noopener"><i class="fab fa-github" aria-hidden="true"></i> {{ $entry }}</a> |
| 48 | + {{- else -}} |
| 49 | + {{ $entry | markdownify }} |
| 50 | + {{- end -}} |
| 51 | +{{- end -}} |
0 commit comments