Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit f38e99e

Browse files
authored
Sync theme changes from docs site
1 parent b1860f3 commit f38e99e

File tree

6 files changed

+164
-58
lines changed

6 files changed

+164
-58
lines changed

‎layouts/_default/_markup/render-link.html‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- /* Last modified: 2023-09-04T09:23:04-07:00 */}}
1+
{{- /* Last modified: 2024-04-26T13:54:00-07:00 */}}
22

33
{{- /*
44
Copyright 2023 Veriphor LLC
@@ -118,7 +118,7 @@
118118
{{- $attrs = merge $attrs (dict "rel" "external") }}
119119
{{- else }}
120120
{{- with $u.Path }}
121-
{{- with $p := or ($.Page.GetPage .) ($.Page.GetPage (strings.TrimRight "/" .)) }}
121+
{{- with $p := or ($.PageInner.GetPage .) ($.PageInner.GetPage (strings.TrimRight "/" .)) }}
122122
{{- /* Destination is a page. */}}
123123
{{- $href := .RelPermalink }}
124124
{{- with $u.RawQuery }}
@@ -137,7 +137,7 @@
137137
{{- end }}
138138
{{- $attrs = dict "href" $href }}
139139
{{- else }}
140-
{{- with $.Page.Resources.Get $u.Path }}
140+
{{- with $.PageInner.Resources.Get $u.Path }}
141141
{{- /* Destination is a page resource; drop query and fragment. */}}
142142
{{- $attrs = dict "href" .RelPermalink }}
143143
{{- else }}
@@ -185,14 +185,14 @@
185185
{{- end }}
186186
{{- end }}
187187
{{- end }}
188-
{{- with .Title }}
189-
{{- $attrs = merge $attrs (dict "title" .) }}
190-
{{- end -}}
188+
{{- $attrs = merge $attrs (dict "title" (.Title | transform.HTMLEscape)) }}
191189

192190
{{- /* Render anchor element. */ -}}
193191
<a
194192
{{- range $k, $v := $attrs }}
195-
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
193+
{{- if $v }}
194+
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
195+
{{- end }}
196196
{{- end -}}
197197
>{{ .Text | safeHTML }}</a>
198198

‎layouts/index.rss.xml‎

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,68 @@
1+
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
12
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
23
<channel>
3-
<title>{{ .Site.Title }} – {{ .Title }}</title>
4+
<title>Hugo News</title>
5+
<description>Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility.</description>
46
<link>{{ .Permalink }}</link>
5-
<description>Recent Hugo news from gohugo.io</description>
6-
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
7-
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
8-
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
9-
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
10-
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
11-
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
12-
<image>
13-
<url>{{ "img/hugo.png" | absURL }}</url>
14-
<title>GoHugo.io</title>
15-
<link>{{ .Permalink }}</link>
16-
</image>
17-
{{ with .OutputFormats.Get "RSS" }}
18-
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
19-
{{ end }}
20-
{{ range first 50 (where .Site.RegularPages "Type" "in" (slice "news" "showcase")) }}
21-
<item>
22-
<title>{{ .Section | title }}: {{ .Title }}</title>
23-
<link>{{ .Permalink }}</link>
24-
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
25-
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
26-
<guid>{{ .Permalink }}</guid>
27-
<description>
28-
{{ $img := (.Resources.ByType "image").GetMatch "*featured*" }}
29-
{{ with $img }}
30-
{{ $img := .Resize "640x" }}
31-
{{ printf "<![CDATA[<img src=\"%s\" width=\"%d\" height=\"%d\"/>]]>" $img.Permalink $img.Width $img.Height | safeHTML }}
32-
{{ end }}
33-
{{ .Content | html }}
34-
</description>
35-
</item>
36-
{{ end }}
7+
<generator>Hugo {{ hugo.Version }}</generator>
8+
<language>{{ or site.Language.LanguageCode site.Language.Lang }}</language>
9+
{{- with site.Copyright }}
10+
<copyright>{{ . }}</copyright>
11+
{{- end }}
12+
{{- with .OutputFormats.Get "RSS" }}
13+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
14+
{{- end }}
15+
16+
{{- $news_items := slice }}
17+
18+
{{- /* Get releases from GitHub. */}}
19+
{{- $u := "https://api.github.com/repos/gohugoio/hugo/releases" }}
20+
{{- $releases := partial "utilities/get-remote-data.html" $u }}
21+
{{- $releases = where $releases "draft" false }}
22+
{{- $releases = where $releases "prerelease" false }}
23+
{{- range $releases | first 20 }}
24+
{{- $summary := printf
25+
"Hugo %s was released on %s. See [release notes](%s) for details."
26+
.tag_name
27+
(.published_at | time.AsTime | time.Format "2 Jan 2006")
28+
.html_url
29+
}}
30+
{{- $ctx := dict
31+
"PublishDate" (.published_at | time.AsTime)
32+
"Title" (printf "Release %s" .name)
33+
"Permalink" .html_url
34+
"Section" "news"
35+
"Summary" ($summary | $.Page.RenderString)
36+
}}
37+
{{- $news_items = $news_items | append $ctx }}
38+
{{- end }}
39+
40+
{{- /* Get content pages from news section. */}}
41+
{{- range where site.RegularPages "Section" "news" }}
42+
{{- $ctx := dict
43+
"PublishDate" .PublishDate
44+
"Title" .Title
45+
"RelPermalink" .RelPermalink
46+
"Section" "news"
47+
"Summary" .Summary
48+
"Params" (dict "description" .Description)
49+
}}
50+
{{- $news_items = $news_items | append $ctx }}
51+
{{- end }}
52+
{{- /* Sort, limit, and render lastBuildDate. */}}
53+
{{- $limit := cond (gt site.Config.Services.RSS.Limit 1) site.Config.Services.RSS.Limit 999 }}
54+
{{- $news_items = sort $news_items "PublishDate" "desc" | first $limit }}
55+
<lastBuildDate>{{ (index $news_items 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
56+
57+
{{- /* Render items. */}}
58+
{{- range $news_items }}
59+
<item>
60+
<title>{{ .Title }}</title>
61+
<link>{{ .Permalink }}</link>
62+
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
63+
<guid>{{ .Permalink }}</guid>
64+
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
65+
</item>
66+
{{- end }}
3767
</channel>
38-
</rss>
68+
</rss>

‎layouts/news/list.html‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1 class="primary-color-dark">
1818

1919
{{/* Get releases from GitHub. */}}
2020
{{ $u := "https://api.github.com/repos/gohugoio/hugo/releases" }}
21-
{{ $releases := partial "inline/get-remote-data.html" $u }}
21+
{{ $releases := partial "utilities/get-remote-data.html" $u }}
2222
{{ $releases = where $releases "draft" false }}
2323
{{ $releases = where $releases "prerelease" false }}
2424
{{ range $releases | first 20 }}
@@ -55,16 +55,3 @@ <h1 class="primary-color-dark">
5555

5656
</div>
5757
{{ end }}
58-
59-
{{ define "partials/inline/get-remote-data.html" }}
60-
{{ $u := . }}
61-
{{ $r := "" }}
62-
{{ with $r = resources.GetRemote $u }}
63-
{{ with .Err }}
64-
{{ errorf "%s" . }}
65-
{{ end }}
66-
{{ else }}
67-
{{ errorf "Unable to get remote resource %q" $u }}
68-
{{ end }}
69-
{{ return ($r | transform.Unmarshal) }}
70-
{{ end }}

‎layouts/news/list.xml‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
2+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
3+
<channel>
4+
<title>Hugo News</title>
5+
<description>Recent news about Hugo, a static site generator written in Go, optimized for speed and designed for flexibility.</description>
6+
<link>{{ .Permalink }}</link>
7+
<generator>Hugo {{ hugo.Version }}</generator>
8+
<language>{{ or site.Language.LanguageCode site.Language.Lang }}</language>
9+
{{- with site.Copyright }}
10+
<copyright>{{ . }}</copyright>
11+
{{- end }}
12+
{{- with .OutputFormats.Get "RSS" }}
13+
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
14+
{{- end }}
15+
16+
{{- $news_items := slice }}
17+
18+
{{- /* Get releases from GitHub. */}}
19+
{{- $u := "https://api.github.com/repos/gohugoio/hugo/releases" }}
20+
{{- $releases := partial "utilities/get-remote-data.html" $u }}
21+
{{- $releases = where $releases "draft" false }}
22+
{{- $releases = where $releases "prerelease" false }}
23+
{{- range $releases | first 20 }}
24+
{{- $summary := printf
25+
"Hugo %s was released on %s. See [release notes](%s) for details."
26+
.tag_name
27+
(.published_at | time.AsTime | time.Format "2 Jan 2006")
28+
.html_url
29+
}}
30+
{{- $ctx := dict
31+
"PublishDate" (.published_at | time.AsTime)
32+
"Title" (printf "Release %s" .name)
33+
"Permalink" .html_url
34+
"Section" "news"
35+
"Summary" ($summary | $.Page.RenderString)
36+
}}
37+
{{- $news_items = $news_items | append $ctx }}
38+
{{- end }}
39+
40+
{{- /* Get content pages from news section. */}}
41+
{{- range .Pages }}
42+
{{- $ctx := dict
43+
"PublishDate" .PublishDate
44+
"Title" .Title
45+
"RelPermalink" .RelPermalink
46+
"Section" "news"
47+
"Summary" .Summary
48+
"Params" (dict "description" .Description)
49+
}}
50+
{{- $news_items = $news_items | append $ctx }}
51+
{{- end }}
52+
{{- /* Sort, limit, and render lastBuildDate. */}}
53+
{{- $limit := cond (gt site.Config.Services.RSS.Limit 1) site.Config.Services.RSS.Limit 999 }}
54+
{{- $news_items = sort $news_items "PublishDate" "desc" | first $limit }}
55+
<lastBuildDate>{{ (index $news_items 0).PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
56+
57+
{{- /* Render items. */}}
58+
{{- range $news_items }}
59+
<item>
60+
<title>{{ .Title }}</title>
61+
<link>{{ .Permalink }}</link>
62+
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
63+
<guid>{{ .Permalink }}</guid>
64+
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
65+
</item>
66+
{{- end }}
67+
</channel>
68+
</rss>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{/*
2+
Parses the serialized data from the given URL and returns a map or an array.
3+
4+
Supports CSV, JSON, TOML, YAML, and XML.
5+
6+
@param {string} . The URL from which to retrieve the serialized data.
7+
@returns {any}
8+
9+
@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }}
10+
*/}}
11+
12+
{{ $url := . }}
13+
{{ $data := dict }}
14+
{{ with resources.GetRemote $url }}
15+
{{ with .Err }}
16+
{{ errorf "%s" . }}
17+
{{ else }}
18+
{{ $data = .Content | transform.Unmarshal }}
19+
{{ end }}
20+
{{ else }}
21+
{{ errorf "Unable to get remote resource %q" $url }}
22+
{{ end }}
23+
{{ return $data }}

‎layouts/shortcodes/new-in.html‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
{{- warnf "This call to the %q shortcode should be removed: %s. The button is now hidden because the specified version (%s) is older than the display threshold." $.Name $.Position $version }}
2828
{{- end }}
2929
{{- else }}
30-
<button class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 mt2 px-4 border border-gray-400 rounded shadow">
31-
<a href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}">New in v{{ $version }}</a>
32-
</button>
30+
<a class="dib f5 fw6 ba bw1 b--gray ph2 mt1" href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}">New in v{{ $version }}</a>
3331
{{- end }}
3432
{{- else }}
3533
{{- errorf "The %q shortcode requires a positional parameter (version). See %s" .Name .Position }}

0 commit comments

Comments
 (0)