diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 73b30291..f503ca4c 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -1,6 +1,7 @@ baseURL = 'https://nginx.org' languageCode = 'en-us' title = 'Example Site' +enableGitInfo = true [module] @@ -18,4 +19,8 @@ maxAge = -1 unsafe = true [markup.highlight] guessSyntax = true - noClasses = false \ No newline at end of file + noClasses = false + +[params] + github_repo = "https://github.com/nginxinc/nginx-hugo-theme" + github_subdir = "exampleSite" \ No newline at end of file diff --git a/layouts/_default/docs.html b/layouts/_default/docs.html index 97ea795a..f92cd2e6 100644 --- a/layouts/_default/docs.html +++ b/layouts/_default/docs.html @@ -39,7 +39,7 @@

{{ .Title }}

{{ if .Page.Lastmod }}
- Last modified {{ .Page.Lastmod.Format "January 2, 2006" }} + {{ partial "page-meta-links" . }}
{{ end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 660060f7..c15b4547 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -41,7 +41,7 @@


{{ if .Page.Lastmod }}
- Last modified {{ .Page.Lastmod.Format "January 2, 2006" }} + {{ partial "page-meta-links" . }}
{{ end }} diff --git a/layouts/partials/page-meta-links.html b/layouts/partials/page-meta-links.html new file mode 100644 index 00000000..db0e4824 --- /dev/null +++ b/layouts/partials/page-meta-links.html @@ -0,0 +1,47 @@ +{{/* cSpell:ignore querify subdir */ -}} +{{/* Class names ending with `--KIND` are deprecated in favor of `__KIND`, but we're keeping them for a few releases after 0.9.0 */ -}} +{{/* Based on https://github.com/google/docsy/blob/main/layouts/partials/page-meta-links.html */}} +{{ if .File -}} +{{ $path := strings.TrimPrefix (add hugo.WorkingDir "/") $.File.Filename -}} +{{ $gh_repo := $.Param "github_repo" -}} +{{ $gh_url := $.Param "github_url" -}} +{{ $gh_subdir := $.Param "github_subdir" | default "" -}} +{{ $gh_branch := $.Param "github_branch" | default "main" -}} +{{ if $gh_url -}} + {{ warnf "Warning: use of `github_url` is deprecated. For details, see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}} + {{ T "post_edit_this" }} +{{ else if $gh_repo -}} + + {{/* Adjust $path based on path_base_for_github_subdir */ -}} + {{ $ghs_base := $.Param "path_base_for_github_subdir" -}} + {{ $ghs_rename := "" -}} + {{ if reflect.IsMap $ghs_base -}} + {{ $ghs_rename = $ghs_base.to -}} + {{ $ghs_base = $ghs_base.from -}} + {{ end -}} + {{ with $ghs_base -}} + {{ $path = replaceRE . $ghs_rename $path -}} + {{ end -}} + + {{ $gh_repo_path := printf "%s/%s/%s" $gh_branch $gh_subdir $path -}} + {{ $gh_repo_path = replaceRE "//+" "/" $gh_repo_path -}} + + {{ $viewURL := printf "%s/tree/%s" $gh_repo $gh_repo_path -}} + {{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path -}} + {{ $issuesURL := printf "%s/issues/new?title=%s&template=2-bug_report.md" $gh_repo (safeURL $.Title ) -}} +
Last modified {{ .Page.Lastmod.Format "January 2, 2006" }}
+
+ View source +
+
+ Edit this page +
+
+ Create a new issue +
+ +{{ end -}} +{{ with .CurrentSection.AlternativeOutputFormats.Get "print" -}} + {{ T "print_entire_section" }} +{{ end }} +{{ end -}} \ No newline at end of file diff --git a/tests/src/__screenshots__/Mobile-Chrome/visual-regression.spec.js/example-site-screenshot.png b/tests/src/__screenshots__/Mobile-Chrome/visual-regression.spec.js/example-site-screenshot.png index a1a3cd7c..faf3f54f 100644 Binary files a/tests/src/__screenshots__/Mobile-Chrome/visual-regression.spec.js/example-site-screenshot.png and b/tests/src/__screenshots__/Mobile-Chrome/visual-regression.spec.js/example-site-screenshot.png differ diff --git a/tests/src/__screenshots__/firefox/visual-regression.spec.js/example-site-screenshot.png b/tests/src/__screenshots__/firefox/visual-regression.spec.js/example-site-screenshot.png index 1a427982..a5844b7d 100644 Binary files a/tests/src/__screenshots__/firefox/visual-regression.spec.js/example-site-screenshot.png and b/tests/src/__screenshots__/firefox/visual-regression.spec.js/example-site-screenshot.png differ diff --git a/tests/src/__screenshots__/webkit/visual-regression.spec.js/example-site-screenshot.png b/tests/src/__screenshots__/webkit/visual-regression.spec.js/example-site-screenshot.png index e53c8751..ab0d3cff 100644 Binary files a/tests/src/__screenshots__/webkit/visual-regression.spec.js/example-site-screenshot.png and b/tests/src/__screenshots__/webkit/visual-regression.spec.js/example-site-screenshot.png differ