Skip to content

Commit ad351f5

Browse files
authored
Merge pull request #265 from samuelkarp/edit-this-page
ui: add Edit this page links (#260)
2 parents 77d4c68 + 31ad4cd commit ad351f5

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

themes/containerd/layouts/docs/list.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,33 @@
2121
</div>
2222

2323
<section class="is-inner-content">
24+
{{- $parts := split (trim .RelPermalink "/") "/" }}
25+
{{- $xVersion := "" }}
26+
{{- if gt (len $parts) 1 }}
27+
{{- $xVersion = index $parts 1 }}
28+
{{- end }}
29+
30+
{{- if ne $xVersion "" }}
31+
{{- $branch := cond (eq $xVersion "main") "main" (printf "release/%s" $xVersion) }}
32+
{{- $relPath := strings.TrimPrefix (printf "docs/%s/" $xVersion) .File.Path }}
33+
34+
{{- $isGenerated := false }}
35+
{{- if and (hasSuffix .File.Path "_index.md") (ne $relPath "_index.md") }}
36+
{{- $isGenerated = true }}
37+
{{- end }}
38+
39+
{{- if not $isGenerated }}
40+
{{- $sourcePath := cond (eq $relPath "_index.md") "README.md" (printf "docs/%s" $relPath) }}
41+
{{- $editUrl := printf "https://github.com/containerd/containerd/edit/%s/%s" $branch $sourcePath }}
42+
43+
<div class="has-text-right mb-3">
44+
<a href="{{ $editUrl }}" target="_blank" class="is-size-6">
45+
<span class="icon is-small"><i class="fas fa-edit"></i></span> Edit this page
46+
</a>
47+
</div>
48+
{{- end }}
49+
{{- end }}
50+
2451
{{- $content := .Content }}
2552
{{ if .Content }}
2653
{{ $content | safeHTML }}

themes/containerd/layouts/docs/single.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,33 @@
2121
</div>
2222

2323
<section class="is-inner-content">
24+
{{- $parts := split (trim .RelPermalink "/") "/" }}
25+
{{- $xVersion := "" }}
26+
{{- if gt (len $parts) 1 }}
27+
{{- $xVersion = index $parts 1 }}
28+
{{- end }}
29+
30+
{{- if ne $xVersion "" }}
31+
{{- $branch := cond (eq $xVersion "main") "main" (printf "release/%s" $xVersion) }}
32+
{{- $relPath := strings.TrimPrefix (printf "docs/%s/" $xVersion) .File.Path }}
33+
34+
{{- $isGenerated := false }}
35+
{{- if and (hasSuffix .File.Path "_index.md") (ne $relPath "_index.md") }}
36+
{{- $isGenerated = true }}
37+
{{- end }}
38+
39+
{{- if not $isGenerated }}
40+
{{- $sourcePath := cond (eq $relPath "_index.md") "README.md" (printf "docs/%s" $relPath) }}
41+
{{- $editUrl := printf "https://github.com/containerd/containerd/edit/%s/%s" $branch $sourcePath }}
42+
43+
<div class="has-text-right mb-3">
44+
<a href="{{ $editUrl }}" target="_blank" class="is-size-6">
45+
<span class="icon is-small"><i class="fas fa-edit"></i></span> Edit this page
46+
</a>
47+
</div>
48+
{{- end }}
49+
{{- end }}
50+
2451
{{- $content := .Content }}
2552
{{ $content | safeHTML }}
2653
</section>

0 commit comments

Comments
 (0)