Skip to content

Commit

Permalink
theme: Format layouts
Browse files Browse the repository at this point in the history
```
npx prettier --write layouts
```
  • Loading branch information
bep committed Feb 18, 2025
1 parent aa3cd83 commit e684310
Show file tree
Hide file tree
Showing 28 changed files with 154 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
**/icons.html
# These are whitespace sensitive.
layouts/_default/_markup/render-code*
layouts/shortcodes/glossary.html

# Odd template syntax.
layouts/_default/_markup/render-heading*
Expand All @@ -13,3 +12,4 @@ layouts/partials/layouts/head/head.html
# Auto generated.
assets/css/components/chroma*.css
assets/jsconfig.json

2 changes: 1 addition & 1 deletion layouts/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<img
src="{{ `images/gopher-side_color.svg` | relURL }}"
alt="gopher"
class="w-32 ml-12 float-right" />
class="w-32 ml-12 float-right">
</h1>

<div class="mt-10 flex items-center justify-center gap-x-6">
Expand Down
47 changes: 25 additions & 22 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{- /* Last modified: 2025-01-19T14:44:56-08:00 */}}

{{- /*
Expand Down Expand Up @@ -76,7 +77,7 @@

@returns {template.html}
*/}}

{{/* prettier-ignore-end */ -}}
{{- /* Initialize. */}}
{{- $renderHookName := "link" }}

Expand Down Expand Up @@ -185,24 +186,26 @@
{{- end }}

{{- /* Render anchor element. */ -}}
<a aria-label="{{ .PlainText }}"
{{- with .Title }} title="{{ . }}" {{- end }}
<a
aria-label="{{ .PlainText }}"
{{- with .Title }}title="{{ . }}"{{- end }}
{{- range $k, $v := $attrs }}
{{- if $v }}
{{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr }}
{{- end }}
{{- end -}}
>{{ .Text }}</a>
>{{ .Text }}</a
>

{{- define "partials/inline/h-rh-l/validate-fragment.html" }}
{{- /*
Validates the fragment portion of a link destination.
Validates the fragment portion of a link destination.

@context {string} contentPath The page containing the link.
@context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error.
@context {page} page The page corresponding to the link destination
@context {struct} parsedURL The link destination parsed by urls.Parse.
@context {string} renderHookName The name of the render hook.
@context {string} contentPath The page containing the link.
@context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error.
@context {page} page The page corresponding to the link destination
@context {struct} parsedURL The link destination parsed by urls.Parse.
@context {string} renderHookName The name of the render hook.
*/}}

{{- /* Initialize. */}}
Expand Down Expand Up @@ -248,20 +251,20 @@

{{- define "partials/inline/h-rh-l/get-glossary-link-attributes.html" }}
{{- /*
Returns the anchor element attributes for a link to the given glossary term.
Returns the anchor element attributes for a link to the given glossary term.

It first checks for the existence of a glossary page for the given term. If
no page is found, it then checks for a glossary page for the singular form of
the term. If neither page exists it throws a warning or error dependent on
the errorLevel setting
It first checks for the existence of a glossary page for the given term. If
no page is found, it then checks for a glossary page for the singular form of
the term. If neither page exists it throws a warning or error dependent on
the errorLevel setting

The returned href attribute does not point to the glossary term page.
Instead, via its fragment, it points to an entry on the glossary page.
The returned href attribute does not point to the glossary term page.
Instead, via its fragment, it points to an entry on the glossary page.

@context {string} contentPath The page containing the link.
@context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error.
@context {string} renderHookName The name of the render hook.
@context {string} text The link text.
@context {string} contentPath The page containing the link.
@context {string} errorLevel The error level when unable to resolve destination; ignore (default), warning, or error.
@context {string} renderHookName The name of the render hook.
@context {string} text The link text.
*/}}

{{- /* Get context.. */}}
Expand Down Expand Up @@ -308,7 +311,7 @@
{{- end }}

{{- /* Create the href attribute. */}}
{{- $href := ""}}
{{- $href := "" }}
{{- if $termActual }}
{{- $href = fmt.Printf "%s#%s" $glossaryPage.RelPermalink (anchorize $termActual) }}
{{- end }}
Expand Down
6 changes: 3 additions & 3 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ define "main" }}
<div class="flex flex-col w-full p-0 m-0">
{{ partial "layouts/home/opensource.html" . }}
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14" />
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14">
{{ partial "layouts/home/sponsors.html" (dict "ctx" . "gtag" "home" ) }}
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14" />
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-14">
{{ partial "layouts/home/features.html" . }}
</div>
{{ end }}
Expand All @@ -15,7 +15,7 @@
<img
src="{{ `images/hugo-logo-wide.svg`| relURL }}"
alt="Hugo Logo"
class="w-64 aspect-3/1 mx-auto mb-8" />
class="w-64 aspect-3/1 mx-auto mb-8">
<h1
class="text-4xl font-bold tracking-tight text-balance text-gray-900 dark:text-gray-300 sm:text-6xl">
The world’s fastest framework for building websites
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/helpers/funcs/get-remote-data.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{/* prettier-ignore-start */ -}}
{{/*
Parses the serialized data from the given URL and returns a map or an array.

Expand All @@ -8,7 +9,7 @@

@example {{ partial "get-remote-data.html" "https://example.org/foo.json" }}
*/}}

{{/* prettier-ignore-end */ -}}
{{ $url := . }}
{{ $data := dict }}
{{ with try (resources.GetRemote $url) }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/helpers/linkcss.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<link
rel="stylesheet"
href="{{ $r.RelPermalink }}"
{{ template `render-attributes` $attr }} />
{{ template `render-attributes` $attr }}>
{{ else }}
{{ with $r | minify | fingerprint }}
<link
rel="stylesheet"
href="{{ .RelPermalink }}"
integrity="{{ .Data.Integrity }}"
crossorigin="anonymous"
{{ template `render-attributes` $attr }} />
{{ template `render-attributes` $attr }}>
{{ end }}
{{ end }}

Expand Down
10 changes: 5 additions & 5 deletions layouts/partials/helpers/picture.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
<source
srcset="{{ $imageWebp.RelPermalink }}"
type="image/webp"
media="(min-width: 1200px)" />
media="(min-width: 1200px)">
<source
srcset="{{ $image.RelPermalink }}"
type="image/jpeg"
media="(min-width: 1200px)" />
<source srcset="{{ $image1xWebp.RelPermalink }}" type="image/webp" />
<source srcset="{{ $image1x.RelPermalink }}" type="image/jpeg" />
media="(min-width: 1200px)">
<source srcset="{{ $image1xWebp.RelPermalink }}" type="image/webp">
<source srcset="{{ $image1x.RelPermalink }}" type="image/jpeg">
<img
class="{{ $class }}"
src="{{ $image1x.RelPermalink }}"
alt=""
width="{{ $image1x.Width }}"
height="{{ $image1x.Height }}" />
height="{{ $image1x.Height }}">
</picture>
7 changes: 4 additions & 3 deletions layouts/partials/layouts/footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<footer class="print:hidden bg-blue-950 mt-8 sm:mt-24 border-t-1 border-gray-800">
<footer
class="print:hidden bg-blue-950 mt-8 sm:mt-24 border-t-1 border-gray-800">
<div class="mx-auto max-w-7xl pt-16 pb-8 sm:pt-18 lg:pt-20">
<div class="xl:grid xl:grid-cols-3 xl:gap-8">
{{/* Column 1 */}}
Expand All @@ -9,13 +10,13 @@
href="https://github.com/gohugoio/hugo/graphs/contributors"
class="text-blue-300 hover:underline"
>Hugo Authors</a
><br />
><br>
</div>

<img
src="/images/hugo-logo-wide.svg"
alt="Hugo Logo"
class="aspect-3/1 w-40" />
class="aspect-3/1 w-40">

<ul class="space-y-2 text-gray-200">
<li class="hover:text-white">
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/layouts/header/qr.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
height="{{ .Height }}"
@load="$event.target.classList.remove('_opacity-0')"
alt="QR code linking to {{ $.page.Permalink }}"
class="{{ $img_class }}" />
class="{{ $img_class }}">
{{ end }}
{{ end }}
2 changes: 1 addition & 1 deletion layouts/partials/layouts/page-edit.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="print:hidden">
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-16" />
<hr class="border-t border-gray-200 dark:border-gray-800 my-10 lg:my-16">

<div class="text-gray-800 dark:text-gray-300 font-semibold">
Last updated:
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/layouts/search/button.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{{ $fillColor = "fill-slate-500 dark:fill-slate-400" }}
{{ end }}


<button
{{ if .standalone }}
x-data @click="$dispatch('search-toggle')"
Expand All @@ -13,7 +14,7 @@
aria-label="Search"
class="{{ $textColor }} grid cursor-pointer w-full lg:w-56 grid-cols-[auto_1fr_auto] items-center rounded-md px-2 sm:px-4 py-2 text-left text-xs/6 lg:text-sm/6 outline-0 sm:outline-1 -outline-offset-1 outline-gray-600">
<svg
class="{{ $fillColor}} pointer-events-none -ml-0.5 mr-2 size-5 sm:size-4">
class="{{ $fillColor }} pointer-events-none -ml-0.5 mr-2 size-5 sm:size-4">
<use href="#icon--search"></use>
</svg>
<span class="hidden lg:inline">Search docs</span>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/layouts/search/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
arial-label="Search"
class="text-gray-800 dark:text-gray-100 bg-white/40 dark:bg-gray-900 shadow rounded border-0 p-3 w-full"
placeholder="Search docs"
x-ref="input" />
x-ref="input">
</div>
</div>
<div class="relative mt-6 flex-1 px-4 sm:px-6">
Expand Down
32 changes: 16 additions & 16 deletions layouts/partials/opengraph/opengraph.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<meta property="og:title" content="{{ .Title }}" />
<meta property="og:title" content="{{ .Title }}">
<meta
property="og:description"
content="{{ with .Description }}
Expand All @@ -9,56 +9,56 @@
{{ else }}
{{ with .Site.Params.description }}{{ . }}{{ end }}
{{ end }}
{{ end }}" />
{{ end }}">
<meta
property="og:type"
content="{{ if .IsPage }}
article
{{ else }}
website
{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">

{{- with $.Params.images -}}
{{- range first 6 . }}
<meta property="og:image" content="{{ . | absURL }}" />
<meta property="og:image" content="{{ . | absURL }}">
{{ end -}}
{{- else -}}
{{- $featured := partial "opengraph/get-featured-image.html" . }}
{{- with $featured -}}
<meta property="og:image" content="{{ $featured.Permalink }}" />
<meta property="og:image" content="{{ $featured.Permalink }}">
{{- else -}}
{{- with $.Site.Params.images }}
<meta property="og:image" content="{{ index . 0 | absURL }}" />
<meta property="og:image" content="{{ index . 0 | absURL }}">
{{ end -}}
{{- end -}}
{{- end -}}

{{- if .IsPage }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section }}" />
<meta property="article:section" content="{{ .Section }}">
{{ with .PublishDate }}
<meta
property="article:published_time"
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end }}
{{ with .Lastmod }}
<meta
property="article:modified_time"
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />
{{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end }}
{{- end -}}

{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}">{{ end }}
{{- with .Params.locale }}
<meta property="og:locale" content="{{ . }}" />
<meta property="og:locale" content="{{ . }}">
{{ end }}
{{- with .Site.Params.title }}
<meta property="og:site_name" content="{{ . }}" />
<meta property="og:site_name" content="{{ . }}">
{{ end }}
{{- with .Params.videos }}
{{- range . }}
<meta property="og:video" content="{{ . | absURL }}" />
<meta property="og:video" content="{{ . | absURL }}">
{{ end }}

{{ end }}
Expand All @@ -71,7 +71,7 @@
{{- $series := index $siteSeries ($name | urlize) }}
{{- range $page := first 6 $series.Pages }}
{{- if ne $page.Permalink $permalink }}
<meta property="og:see_also" content="{{ $page.Permalink }}" />
<meta property="og:see_also" content="{{ $page.Permalink }}">
{{ end }}
{{- end }}
{{ end }}
Expand All @@ -80,5 +80,5 @@

{{- /* Facebook Page Admin ID for Domain Insights */}}
{{- with site.Params.social.facebook_admin }}
<meta property="fb:admins" content="{{ . }}" />
<meta property="fb:admins" content="{{ . }}">
{{ end }}
11 changes: 5 additions & 6 deletions layouts/shortcodes/chroma-lexers.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<dl>
{{ range .Site.Data.docs.chroma.lexers }}
<dt>{{ .Name }}</dt>
<dd>{{ with .Aliases }}{{ delimit . ", " }}{{ end }}</dd>
{{ end }}
</dl>

{{ range .Site.Data.docs.chroma.lexers }}
<dt>{{ .Name }}</dt>
<dd>{{ with .Aliases }}{{ delimit . ", " }}{{ end }}</dd>
{{ end }}
</dl>
Loading

0 comments on commit e684310

Please sign in to comment.