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 e9137b6 commit 38bccdd
Show file tree
Hide file tree
Showing 27 changed files with 320 additions and 303 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,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
116 changes: 59 additions & 57 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
{{- /* Last modified: 2025-01-19T14:44:56-08:00 */}}

{{- /*
Copyright 2025 Veriphor LLC
Copyright 2025 Veriphor LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

https://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
*/}}

{{- /*
This render hook resolves internal destinations by looking for a matching:
This render hook resolves internal destinations by looking for a matching:

1. Content page
2. Page resource (a file in the current page bundle)
3. Section resource (a file in the current section)
4. Global resource (a file in the assets directory)

It skips the section resource lookup if the current page is a leaf bundle.
It skips the section resource lookup if the current page is a leaf bundle.

External destinations are not modified.
External destinations are not modified.

You must place global resources in the assets directory. If you have placed
your resources in the static directory, and you are unable or unwilling to move
them, you must mount the static directory to the assets directory by including
both of these entries in your site configuration:
You must place global resources in the assets directory. If you have placed
your resources in the static directory, and you are unable or unwilling to move
them, you must mount the static directory to the assets directory by including
both of these entries in your site configuration:

[[module.mounts]]
source = 'assets'
Expand All @@ -41,40 +41,40 @@
source = 'static'
target = 'assets'

By default, if this render hook is unable to resolve a destination, including a
fragment if present, it passes the destination through without modification. To
emit a warning or error, set the error level in your site configuration:
By default, if this render hook is unable to resolve a destination, including a
fragment if present, it passes the destination through without modification. To
emit a warning or error, set the error level in your site configuration:

[params.render_hooks.link]
errorLevel = 'warning' # ignore (default), warning, or error (fails the build)

When you set the error level to warning, and you are in a development
environment, you can visually highlight broken internal links:
When you set the error level to warning, and you are in a development
environment, you can visually highlight broken internal links:

[params.render_hooks.link]
errorLevel = 'warning' # ignore (default), warning, or error (fails the build)
highlightBroken = true # true or false (default)

This will add a "broken" class to anchor elements with invalid src attributes.
Add a rule to your CSS targeting the broken links:
This will add a "broken" class to anchor elements with invalid src attributes.
Add a rule to your CSS targeting the broken links:

a.broken {
background: #ff0;
border: 2px solid #f00;
padding: 0.1em 0.2em;
background: #ff0;
border: 2px solid #f00;
padding: 0.1em 0.2em;
}

This render hook may be unable to resolve destinations created with the ref and
relref shortcodes. Unless you set the error level to ignore you should not use
either of these shortcodes in conjunction with this render hook.
This render hook may be unable to resolve destinations created with the ref and
relref shortcodes. Unless you set the error level to ignore you should not use
either of these shortcodes in conjunction with this render hook.

@context {string} Destination The link destination.
@context {page} Page A reference to the page containing the link.
@context {string} PlainText The link description as plain text.
@context {string} Text The link description.
@context {string} Title The link title.
@context {string} Destination The link destination.
@context {page} Page A reference to the page containing the link.
@context {string} PlainText The link description as plain text.
@context {string} Text The link description.
@context {string} Title The link title.

@returns {template.html}
@returns {template.html}
*/}}

{{- /* Initialize. */}}
Expand Down Expand Up @@ -185,24 +185,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 +250,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 +310,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
13 changes: 6 additions & 7 deletions layouts/partials/helpers/funcs/get-remote-data.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{{/*
Parses the serialized data from the given URL and returns a map or an array.
{{/* Parses the serialized data from the given URL and returns a map or an array.

Supports CSV, JSON, TOML, YAML, and XML.
Supports CSV, JSON, TOML, YAML, and XML.

@param {string} . The URL from which to retrieve the serialized data.
@returns {any}
@param {string} . The URL from which to retrieve the serialized data.
@returns {any}

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

{{ $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
Loading

0 comments on commit 38bccdd

Please sign in to comment.