Skip to content

Commit 4c2a990

Browse files
authored
Hugo: Update remote resource handling for version bump (#280)
* Hugo: Update remote resource handling for version bump * Hugo: Move docs template content to default single template * CI: Update build-push action sha
1 parent 0a682c4 commit 4c2a990

File tree

6 files changed

+77
-89
lines changed

6 files changed

+77
-89
lines changed

.github/workflows/build-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111

1212
jobs:
1313
deploy-example-site:
14-
uses: nginxinc/docs-actions/.github/workflows/docs-build-push.yml@9c59fab05a8131f4d691ba6ea2b6a119f3ef832a # v1.0.7
14+
uses: nginxinc/docs-actions/.github/workflows/docs-build-push.yml@285440f02d9967b62aeb1b7e0b5c2c70d4f950cf # v1.0.10
1515
with:
1616
production_url_path: "/nginx-hugo-theme"
1717
preview_url_path: "/previews/nginx-hugo-theme"

layouts/_default/docs.html

Lines changed: 0 additions & 73 deletions
This file was deleted.

layouts/_default/single.html

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,72 @@
1-
{{ .Render "docs" }}
1+
{{ define "main" }}
2+
<div class="docs-container row override-sidebar-collapse">
3+
<nav id="sidebar" class="sidenav overflow-auto col-md-3 d-none d-xl-block d-print-none align-top">
4+
{{ partial "sidebar.html" . }}
5+
</nav>
26

7+
<!-- Replace icons -->
8+
{{ $content := partial "icon-replacement.html" (dict "content" .Content) }}
9+
10+
{{if (.Params.catalog) }}
11+
<main class="content content-has-toc" role="main">
12+
{{ else if and (gt .WordCount 200 ) (.Params.toc) }}
13+
<main class="content col d-block align-top content-has-toc" role="main">
14+
{{ else }}
15+
<main class="content col d-block align-top content-no-toc" role="main">
16+
{{ end }}
17+
18+
<section class="main-layout">
19+
<div class="sidebar-layout" id="sidebar-layout">
20+
<button class="sidebar__mobile__toggle" aria-expanded="false" data-mf="true">{{ partial "lucide" (dict "context" . "icon" "x")}}Close</button>
21+
<nav data-mf="true" id="sidebar-v2" class="sidebar">
22+
{{ partial "sidebar-v2.html" . }}
23+
</nav>
24+
</div>
25+
26+
<section id="maincontent" class="content-layout">
27+
<div data-cms-edit="content" class="text-content">
28+
<section class="breadcrumb-layout wide" data-mf="true" style="display: none;">
29+
{{ if not .IsHome }}
30+
{{ if not (in .Params.display_breadcrumb "false" ) }}
31+
{{ partial "breadcrumb" .}}
32+
{{ end }}
33+
{{ end }}
34+
</section>
35+
{{ partial "banner" .}}
36+
<h1>{{ .Title }}</h1>
37+
{{ $content | safeHTML }}
38+
{{ if eq .Page.Draft true }}{{ partial "draft-badge.html" . }}{{ end }}
39+
{{ if in .Params.doctypes "beta" }}{{ partial "beta-badge" . }}{{ end }}
40+
41+
<hr>
42+
43+
{{ if .Page.Lastmod }}
44+
<div class="last-modified">
45+
{{ partial "page-meta-links" . }}
46+
</div>
47+
{{ end }}
48+
49+
{{ partial "version-list" . }}
50+
{{ partial "qualtrics-feedback.html" }}
51+
52+
{{ partial "previous-next-links-in-section-with-title.html" . }}
53+
</main>
54+
{{ if and (gt .WordCount 200 ) (.Params.toc) }}
55+
{{ if (add (len (findRE "<h3" .Content)) (len (findRE "<h2" .Content))) }}
56+
<div id="toc" class="col-md-3 d-none d-xl-block d-print-none nginx-toc align-top">
57+
{{ partial "toc.html" . }}
58+
</div>
59+
{{ end }}
60+
{{ end }}
61+
62+
</div>
63+
</section>
64+
</section>
65+
</div>
66+
<!-- If there is a script defined in the page metadata, load it -->
67+
{{if .Params.script}}
68+
{{ $script := (delimit (slice "scripts" .Params.script) "/")}}
69+
{{ partial (string $script) .}}
70+
{{end }}
71+
72+
{{ end }}

layouts/shortcodes/dimensions.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
{{ $jsPath := replace $rawJSPath "/static" "" }}
44
{{ $dimensionsRef := dict }}
55
{{ with resources.Get $jsPath }}
6-
{{ with .Err }}
7-
{{ errorf "%s" . }}
8-
{{ else }}
96
{{ $dimensionsRef = . | transform.Unmarshal }}
10-
{{ end }}
117
{{ else }}
12-
{{ errorf "Unable to get asset resource %q" $jsPath }}
8+
{{ errorf "Unable to get asset resource %q" $jsPath }}
139
{{ end }}
1410

15-
1611
<div class="row flex-xl-nowrap">
1712

1813

layouts/shortcodes/ghcode.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{{ $file := .Get 0 }}
22
{{ $params := .Get 1 }}
33
{{ $codeBlockId := printf "id-%x" (now.UnixNano) }}
4-
{{ with resources.GetRemote $file }}
4+
{{ with try (resources.GetRemote $file) }}
55
{{ with .Err }}
66
{{ errorf "%s" . }}
77
{{ else }}
88
{{ $lang := path.Ext $file | strings.TrimPrefix "." }}
99
<div id="code-block-v1" data-mf="false">
10-
{{ highlight .Content $lang $params }}
10+
{{ highlight .Value $lang $params }}
1111
</div>
1212

1313
<div class="code-block" data-mf="true" style="display: none;">
@@ -17,10 +17,10 @@
1717
<div class="code-container chroma">
1818
<button onclick="copyToClipBoard(this, {{ $codeBlockId }})" class="code-copy-button multi-line" type="button">Copy</button>
1919
<div class="highlight-v2" id="{{ $codeBlockId }}">
20-
{{ highlight .Content $lang $params }}
20+
{{ highlight .Value $lang $params }}
2121
</div>
2222
</div>
23-
</div>
23+
</div>
2424
{{ end }}
2525
{{ else }}
2626
{{ errorf "Unable to load github content from %s from %q" $file .Position}}

layouts/shortcodes/metrics.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
{{ $jsPath := replace $rawJSPath "/static" "" }}
44
{{ $metricsRef := dict }}
55
{{ with resources.Get $jsPath }}
6-
{{ with .Err }}
7-
{{ errorf "%s" . }}
8-
{{ else }}
96
{{ $metricsRef = . | transform.Unmarshal }}
10-
{{ end }}
117
{{ else }}
128
{{ errorf "Unable to get asset resource %q" $jsPath }}
139
{{ end }}

0 commit comments

Comments
 (0)