Update theme

This commit is contained in:
Joe Mooring 2023-11-11 16:34:19 -08:00 committed by GitHub
parent 0f0ab2adee
commit 0c4bc14477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 169 additions and 817 deletions

View File

@ -0,0 +1,20 @@
/*
Make h6 elements behave like dt elements. Initially implemented to support
linkable glossary entries.
Yes, it's a hack. That's why it's in the shame file.
*/
h6 {
margin-top: 0;
margin-bottom: 0;
font-size: 1.125rem;
}
h6:first-of-type {
margin-top: 3em;
}
h6 ~ p {
margin: 0.5em 0 2em 0;
}

View File

@ -22,19 +22,17 @@
@import '_social-icons';
@import '_stickyheader';
@import '_right-sidebar';
@import '_svg';
@import '_chroma';
@import '_variables';
@import '_print';
@import '_shame';
.nested-blockquote blockquote {
border-left: 4px solid var(--primary-color);
padding-left: 1em;
/*margin: 0;*/
}
.mw-90 {
max-width:90%;
}

View File

@ -5322,10 +5322,26 @@ code, .code, pre code, .highlight pre {
display: none;
}
}
/*
Make h6 elements behave like dt elements. Initially implemented to support
linkable glossary entries.
Yes, it's a hack. That's why it's in the shame file.
*/
h6 {
margin-top: 0;
margin-bottom: 0;
font-size: 1.125rem;
}
h6:first-of-type {
margin-top: 3em;
}
h6 ~ p {
margin: 0.5em 0 2em 0;
}
.nested-blockquote blockquote {
border-left: 4px solid #0594CB;
padding-left: 1em;
/*margin: 0;*/
}
.mw-90 {
max-width:90%;

View File

@ -1,5 +1,5 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}
{{- if and (ge .Level 2) (le .Level 4) }}{{" " -}}
{{- if in (slice 2 3 4 6) .Level }}{{" " -}}
<a class="header-link" href="#{{ .Anchor | safeURL }}"><svg class="fill-current o-60 hover-accent-color-light" height="22px" viewBox="0 0 24 24" width="22px" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z" fill="none"/><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg></a>
{{- end -}}
</h{{ .Level }}>

View File

@ -95,7 +95,7 @@
{{- partial "opengraph/twitter_cards.html" . -}}
{{ if hugo.IsProduction }}
{{ partial "gtag" . }}
{{ partial "gtag.html" . }}
{{ end }}
</head>
@ -104,7 +104,7 @@
class="ma0 sans-serif bg-primary-color-light{{ with getenv "HUGO_ENV" }}
{{ . }}
{{ end }}">
{{ partial "hooks/after-body-start" . }}
{{ partial "hooks/after-body-start.html" . }}
{{ block "nav" . }}{{ partial "site-nav.html" . }}{{ end }}
{{ block "header" . }}{{ end }}
<main role="main" class="content-with-sidebar min-vh-100 pb7 pb0-ns">
@ -113,7 +113,7 @@
{{ block "footer" . }}{{ partialCached "site-footer.html" . }}{{ end }}
{{ partial "hooks/before-body-end" . }}
{{ partial "hooks/before-body-end.html" . }}
</body>
</html>

View File

@ -38,7 +38,7 @@
<img src="{{ . }}" alt="Featured Image for {{ $.Title }}" class="mw-100">
{{ end }}
<div class="prose prose-{{ .Type }}" id="prose">
<div class="prose" id="prose">
<div class="mb4">
{{- partial "docs/functions-signatures.html" . -}}
{{- partial "docs/functions-return-type.html" . -}}

View File

@ -13,7 +13,7 @@
</div>
</div>
<div id="right-sidebar" class="order-2 w-20 dn db-l sticky pt2">
{{ partial "right-sidebar" . }}
{{ partial "right-sidebar.html" . }}
</div>
</div>

View File

@ -1,27 +1,27 @@
{{ define "header" }}
{{ partial "hero" . }}
{{ partial "boxes-small-news" . }}
{{ partial "hero.html" . }}
{{ partial "boxes-small-news.html" . }}
{{ end }}
{{ define "main" }}
<section class="w-100 ph4 ph5-ns pv4">
{{- partial "home-page-sections/features-icons" . -}}
{{- partial "home-page-sections/features-icons.html" . -}}
</section>
{{ partial "home-page-sections/sponsors.html" (dict "cx" . "gtag" "home" ) }}
{{- partial "home-page-sections/features-single" . -}}
{{- partial "home-page-sections/features-single.html" . -}}
{{- partial "home-page-sections/showcase.html" . -}}
<section class="w-100 ph4 ph5-ns pv4 pv6-ns mid-gray bg-white bb bt b--light-gray">
{{- partial "home-page-sections/installation" . -}}
{{- partial "home-page-sections/installation.html" . -}}
</section>
<section class="w-100 ph4 ph5-ns pv4 pv6-ns mid-gray bg-accent-color-dark">
{{- partial "home-page-sections/tweets" . -}}
{{- partial "home-page-sections/tweets.html" . -}}
</section>
<section class="w-100 ph4 ph5-ns pt4 pb5 mid-gray bg-primary-color-light bb bt b--light-gray ">
{{- partial "home-page-sections/open-source-involvement" . -}}
{{- partial "home-page-sections/open-source-involvement.html" . -}}
</section>
{{ end }}

View File

@ -47,7 +47,7 @@
{{/* Sort by date (descending) and render. */}}
{{ range sort $news_items "Date" "desc" }}
{{ partial "boxes-section-summaries" (dict "context" . "classes" $interior_classes "fullcontent" false) }}
{{ partial "boxes-section-summaries.html" (dict "context" . "classes" $interior_classes "fullcontent" false) }}
{{ end }}
</section>

View File

@ -34,9 +34,6 @@
Go to <a href="https://github.com/gohugoio/hugo/releases" class="link primary-color dim">Hugo Releases</a> for the release downloads.
</p>
{{ end }}
<!--
NOTE: Removed to test builds without it.
partial "components/author-github-data" (dict "context" . "size" "110") -->
<div class="nested-links mt4">
{{- partial "previous-next-links-in-section.html" . -}}

View File

@ -6,6 +6,7 @@
<div class="flex-ns flex-wrap justify-between">
{{ if $.Site.Data.homepagetweets }}
{{ range first 4 (sort $.Site.Data.homepagetweets.tweet "date" "desc" ) }}
<div class="homepage-tweet relative {{ $interior_classes }} br1 mid-gray pv3 nested-links shadow-5">
<div class="absolute top-0 left-0 ma2 o-10">
@ -21,5 +22,6 @@
</blockquote>
</div>
{{ end }}
{{ end }}
</div>
</div>

View File

@ -9,8 +9,8 @@
</a>
</div>
{{ partial "nav-links" .}}
{{ partial "nav-links.html" .}}
<div class="dn-l">
{{ partial "nav-button-open" .}}
{{ partial "nav-button-open.html" .}}
</div>
</header>

View File

@ -24,7 +24,7 @@
{{ $pages = $.context.Pages }}
{{ end }}
{{ range $pages }}
{{ partial "boxes-section-summaries" (dict "context" . "classes" $interior_classes "fullcontent" true) }}
{{ partial "boxes-section-summaries.html" (dict "context" . "classes" $interior_classes "fullcontent" true) }}
{{ end }}
</section>
</div>

View File

@ -1,13 +0,0 @@
<!-- TOCs need to be declared explicitly in the front matter of content/*.md -->
<aside class="fixed-lTK mw5-l right-0 f6 bl-l b--moon-gray pv4 pv0-ns ph4-l nested-list-reset nested-links nested-copy-line-height">
{{ if .Params.toc }}
<p class="b">What's on this Page</p>
{{ .TableOfContents }}
{{ end }}
{{- partial "previous-next-links-in-section.html" . -}}
{{- if .Params.godocref -}}
<a target="_blank" class="tooltip right godoc-link" data-tooltip="See the related Godocs for {{.Title }}" href="{{.Params.godocref}}" >
</a>
{{- end -}}
</aside>

View File

@ -2,7 +2,7 @@
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
@param {string} [config] The section of site.Data.docs.config to render.
@param {bool} [copy=true] If true, display a copy to clipboard button.
@param {bool} [copy=false] If true, display a copy to clipboard button.
@param {string} [file] The file name to display above the rendered code.
@param {bool} [fm=false] If true, render the code as front matter.
@param {bool} [skipHeader=false] If false, omit top level key(s) when rendering a section of site.Data.docs.config.

View File

@ -1,26 +1,22 @@
{{- /*
Renders syntax highlighted code.
@param {bool} [copy=true] If true, display a copy to clipboard button.
@param {bool} [copy=false] If true, display a copy to clipboard button.
@param {string} [file] The file name to display above the rendered code.
@param {string} [lang] The code language of the inner content.
@returns {template.HTML}
*/}}
{{- /* Initialize. */}}
{{- $copy := false }}
{{- $file := "&nbsp;" }}
{{- $lang := "" }}
{{- /* Get parameters. */}}
{{- $file = .Get "file" }}
{{- $lang = or (.Get "lang") (path.Ext $file | strings.TrimPrefix ".") "text" }}
{{- $copy := false }}
{{- if in (slice "false" false 0) (.Get "copy") }}
{{- $copy = false }}
{{- else if in (slice "true" true 1) (.Get "copy")}}
{{- $copy = true }}
{{- end }}
{{- $file := or (.Get "file") "&nbsp;" }}
{{- $lang := or (.Get "lang") (path.Ext $file | strings.TrimPrefix ".") "text" }}
{{- /* Use the go-html-template Chroma lexer for HTML. */}}
{{- if eq $lang "html" }}
@ -29,7 +25,7 @@ Renders syntax highlighted code.
{{- /* Render. */}}
<div class="code relative" id="{{ $file | urlize }}">
<div class="f6 dib lh-solid pl2 pv2">{{ or $file "nbsp;" }}</div>
<div class="f6 dib lh-solid pl2 pv2">{{ $file | htmlUnescape }}</div>
{{- if $copy }}
<button class="needs-js copy bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
{{- end }}

View File

@ -1,13 +0,0 @@
{{- $pathURL := .Get "pathURL" -}}
{{- $path := .Get "path" -}}
{{- $files := readDir $path -}}
<table>
<th>Size in bytes</th>
<th>Name</th>
{{- range $files }}
<tr>
<td>{{ .Size }}</td>
<td><a href="{{ $pathURL }}{{ .Name | relURL }}" target="_blank"> {{ .Name }}</a></td>
</tr>
{{- end }}
</table>

View File

@ -1,11 +0,0 @@
{{ $file := .Get 0}}
{{ $filepath := $file }}
{{ $syntax := index (split $file ".") 1 }}
{{ $syntaxoverride := eq (len .Params) 2 }}
<div class="code-copy" id="{{$file | urlize}}">
<div class="code-copy-header"><div class="action-buttons"></div><span title="" class="filename">{{$filepath}}</span><i class="icon-{{$syntax}} input"></i></div>
<button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
<div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
</button>
<pre><code class="language-{{if $syntaxoverride}}{{.Get 1}}{{else}}{{$syntax}}{{end}}">{{- readFile $file -}}</code></pre>
</div>

View File

@ -1,12 +0,0 @@
{{ $file := .Get 0}}
{{ $filepath := replace $file "static/" ""}}
{{ $syntax := index (split $file ".") 1 }}
{{ $syntaxoverride := eq (len .Params) 2 }}
<div class="code-copy" id="{{$file | urlize}}">
<div class="code-copy-header examplesite"><div class="action-buttons"></div><span class="filename"><i class="icon-website"></i>{{$filepath}}</span><i class="icon-{{$syntax}} input"></i></div>
<button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
<div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
</button>
<pre><code class="language-{{if $syntaxoverride}}{{.Get 1}}{{else}}{{$syntax}}{{end}}">{{- readFile $file -}}</code></pre>
<a role="button" target="_blank" href="{{$.Site.Params.ghdocsrepo}}{{$file}}" title="See {{$filepath}} source on GitHub" class="tooltip see-on-github" data-tooltip="See {{$filepath}} source on GitHub">Source<i class="icon-github"></i></a>
</div>

View File

@ -1,13 +0,0 @@
<!-- Similar to exfile.html but *only* pulls the front matter from the example/content/*md -->
{{ $file := .Get 0}}
{{ $filepath := replace $file "static/" ""}}
{{ $syntax := index (split $file ".") 1 }}
{{ $syntaxoverride := eq (len .Params) 2 }}
<div class="code-copy" id="{{$file | urlize}}">
<div class="code-copy-header examplesite"><div class="action-buttons"></div><span title="" class="filename">{{$filepath}}</span><i class="icon-{{$syntax}} input"></i></div>
<button class="copy-button" title="Copy to clipboard" data-clipboard-snippet>
<div class="copy-text"><i class="icon-clipboard"></i> COPY</div>
</button>
<pre><code class="language-{{if $syntaxoverride}}{{.Get 1}}{{else}}{{$syntax}}{{end}}">{{- readFile $file -}}</code></pre>
<a role="button" target="_blank" href="{{$.Site.Params.ghdocsrepo}}{{$file}}" title="See {{$filepath}} on GitHub" class="see-on-github">Source<i class="icon-github"></i></a>
</div>

View File

@ -1,9 +0,0 @@
{{ range .Params }}
{{ if eq (substr . 0 1) "@" }}
<a href="//github.com/{{ substr . 1 }}">{{ . }}</a>
{{ else if eq (substr . 0 2) "0x" }}
<a href="//github.com/gohugoio/hugo/commit/{{ substr . 2 }}">{{ substr . 2 6 }}</a>
{{ else }}
<a href="//github.com/gohugoio/hugo/issues/{{ . }}">#{{ . }}</a>
{{ end }}
{{ end }}

View File

@ -1 +0,0 @@
<a href="{{$.Site.Params.ghrepo}}" target="_blank">GitHub repository</a>

View File

@ -316,9 +316,9 @@ Renders the given image using the given filter, if any.
{{- /* Render. */}}
{{- if $example }}
<p>{{ or (T "original") "original" | strings.FirstUpper }}</p>
<p>Original</p>
<img class='di ba b--black-20' style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
<p>{{ or (T "processed") "processed" | strings.FirstUpper }}</p>
<p>Processed</p>
<img class='di ba b--black-20' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
{{- else -}}
<img class='di' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">

View File

@ -6,7 +6,7 @@ Renders the given image using the given process specification.
@returns template.HTML
@example {{< imgproc "sunset.jpg" "resize 300x" }}
@example {{< imgproc "sunset.jpg" "resize 300x" />}}
*/}}
{{- with $.Get 0 }}

View File

@ -4,7 +4,7 @@
{{ end }}
{{ $version = $version | strings.TrimPrefix "v" }}
<button
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 ml2 px-4 border border-gray-400 rounded shadow">
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 px-4 border border-gray-400 rounded shadow">
<a
href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}"
target="_blank"

View File

@ -1 +0,0 @@
<pre><code class="nohighlight">{{ .Inner }}</code></pre>

View File

@ -1,9 +1,7 @@
{{ $_hugo_config := `{ "version": 1 }` }}
<aside class="admonition note">
<div class="note-icon">
{{partial "svg/exclamation.svg" (dict "size" "20px" ) }}
<aside>
<div class="admonition-content bl bw2 b--blue" >
{{ .Inner }}
</div>
<!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}note{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Note{{end}}</h2> -->
<!-- <h3>Note</h3> -->
<div class="admonition-content">{{- .Inner -}}</div>
</aside>

View File

@ -1,11 +0,0 @@
{{$file := .Get "file"}}
{{$icon := index (split $file ".") 1 }}
<div class="code" id="{{$file | urlize}}">
<div class="filename" title="{{$file}}">{{$file}}</div>
<!-- <div class="code-icon">
<i class="icon-{{$icon}}"></i>
</div> -->
<div class="code-copy-content output-content">
{{- .Inner -}}
</div>
</div>

View File

@ -1,9 +0,0 @@
{{ $_hugo_config := `{ "version": 1 }` }}
<aside class="admonition tip">
<div class="tip-icon">
{{partial "svg/exclamation.svg" .}}
</div>
<!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}tip{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Tip{{end}}</h2> -->
<!-- <h3>Tip</h3> -->
<div class="admonition-content">{{- .Inner -}}</div>
</aside>

View File

@ -1,9 +0,0 @@
{{ $_hugo_config := `{ "version": 1 }` }}
<aside class="admonition warning">
<div class="admonition-icon">
{{partial "svg/exclamation.svg" .}}
</div>
<!-- <h2 id="{{if .Get 0}}{{.Get 0 | urlize}}{{else}}warning{{end}}">{{if .Get 0}}{{.Get 0 | markdownify}}{{else}}Warning{{end}}</h2> -->
<!-- <h3>Warning</h3> -->
<div class="admonition-content">{{- .Inner -}}</div>
</aside>

View File

@ -1,11 +0,0 @@
<div class="video-wrapper" data-streaming="youtube" data-videoid="{{.Get "id"}}" >
<i class="icon-video-play-button shortcode"></i>
{{if (.Get "thumbnail")}}
<div style="background-image:url(/images/thumbnails/{{.Get "thumbnail"}})" alt="YouTube Thumbnail" class="video-thumbnail"></div>
{{else}}
<div style="background-image:url(//img.youtube.com/vi/{{.Get "id"}}/0.jpg)" alt="YouTube Thumbnail" class="video-thumbnail"></div>
{{end}}
</div>
{{ if (.Get "description") }}
<div class="video-description">{{ .Get "description" | markdownify }}</div>
{{ end }}

View File

@ -1 +1 @@
# github.com/gohugoio/gohugoioTheme v0.0.0-20231109022943-a05c967b35f8
# github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e

View File

@ -26,7 +26,7 @@ For documentation related to a new feature, please include the documentation cha
Please follow these markdown guidelines:
- Use [ATX] headings, not [setext] headings
- Use [ATX] headings, not [setext] headings, levels 2 through 4
- Use [fenced code blocks], not [indented code blocks]
- Use hyphens, not asterisks, with unordered [list items]
- Use the [note shortcode] instead of blockquotes
@ -92,6 +92,12 @@ Other guidelines to consider:
- When including code samples, use short snippets that demonstrate the concept.
- The Hugo user community is global; use [basic english](https://simple.wikipedia.org/wiki/Basic_English) when possible.
#### Level 6 markdown headings
Level 6 markdown headings are styled as `dt` elements. This was implemented to support a [glossary] with linkable terms.
[glossary]: /getting-started/glossary
## Code examples
Indent code by two spaces. With examples of template code, include a space after opening action delimiters, and include a space before closing action delimeters.

View File

@ -8,83 +8,82 @@ menu:
parent: getting-started
weight: 60
weight: 60
type: glossary
# Use level 3 headings for each term in the glossary.
# Use level 6 headings for each term in the glossary.
---
### action
###### action
See [template action](#template-action).
### archetype
###### archetype
A template for new content. See&nbsp;[details](/content-management/archetypes/).
### argument
###### argument
A [scalar](#scalar), [array](#array), [slice](#slice), [map](#map), or [object](#object) passed to a [function](#function), [method](#method), or [shortcode](#shortcode).
### array
###### array
A numbered sequence of elements. Unlike Go's [slice](#slice) data type, an array has a fixed length. [Elements](#element) within an array can be [scalars](#scalar), slices, [maps](#map), pages, or other arrays. See the [Go&nbsp;documentation](https://go.dev/ref/spec#Array_types) for details.
### bool
###### bool
See [boolean](#boolean).
### boolean
###### boolean
A data type with two possible values, either `true` or `false`.
### branch bundle
###### branch bundle
A [page bundle](#page-bundle) with an&nbsp;_index.md file and zero or more [resources](#resource). Analogous to a physical branch, a branch bundle may have descendants including regular pages, [leaf bundles](/getting-started/glossary/#leaf-bundle), and other branch bundles. See&nbsp;[details](/content-management/page-bundles/).
### build
###### build
To generate a static site that includes HTML files and assets such as images, CSS, and JavaScript. The build process includes rendering and resource transformations.
### bundle
###### bundle
See [page bundle](#page-bundle).
### cache
###### cache
A software component that stores data so that future requests for the same data are faster.
### chain
###### chain
Within a template, to connect one or more [identifiers](#identifier) with a dot. An identifier can represent a method, object, or field. For example, `.Site.Params.author.name` or `.Date.UTC.Hour`.
### collection
###### collection
An [array](#array), [slice](#slice), or [map](#map).
### content format
###### content format
A markup language for creating content. Typically markdown, but may also be HTML, AsciiDoc, Org, Pandoc, or reStructuredText. See&nbsp;[details](/content-management/formats/).
### content type
###### content type
A classification of content inferred from the top-level directory name or the `type` set in [front matter](#front-matter). Pages in the root of the content directory, including the home page, are of type "page". Accessed via `.Page.Type` in [templates](#template). See&nbsp;[details](/content-management/types/).
### content view
###### content view
A template called with the `.Page.Render` method. See&nbsp;[details](/templates/views/).
### context
###### context
Represented by a dot "." within a [template action](#template-action), context is the current location in a data structure. For example, while iterating over a [collection](#collection) of pages, the context within each iteration is the page's data structure. The context received by each template depends on template type and/or how it was called. See&nbsp;[details](/templates/introduction/#the-dot).
### default sort order
###### default sort order
The default sort order for page collections. Hugo sorts by [weight](#weight), then by date (descending), then by link title, and then by file path.
### element
###### element
A member of a slice or array.
### environment
###### environment
Typically one of `development`, `staging`, or `production`, each environment may exhibit different behavior depending on configuration and template logic. For example, in a production environment you might minify and fingerprint CSS, but that probably doesn't make sense in a development environment.
@ -94,31 +93,31 @@ To determine the current environment within a template, use the [`hugo.Environme
[`hugo.Environment`]: /functions/hugo/environment
### flag
###### flag
An option passed to a command-line program, beginning with one or two hyphens. See&nbsp;[details](/commands/hugo/).
### float
###### float
See [floating point](#floating-point).
### floating point
###### floating point
A numeric data type with a fractional component. For example, `3.14159`.
### fragment
###### fragment
The final segment of a URL, beginning with a hash (`#`) mark, that references an `id` attribute of an HTML element on the page.
### front matter
###### front matter
Metadata at the beginning of each content page, separated from the content by format-specific delimiters. See&nbsp;[details](/content-management/front-matter/).
### function
###### function
Used within a [template action](#template-action), a function takes one or more [arguments](#argument) and returns a value. Unlike [methods](#method), functions are not associated with an [object](#object). See&nbsp;[details](/functions/).
### global resource
###### global resource
A file within the assets directory, or within any directory [mounted](/hugo-modules/configuration/#module-configuration-mounts) to the assets directory. Capture one or more global resources using the [`resources.Get`], [`resources.GetMatch`], [`resources.Match`], or [`resources.ByType`] functions.
@ -127,158 +126,158 @@ A file within the assets directory, or within any directory [mounted](/hugo-modu
[`resources.Match`]: /functions/resources/match
[`resources.ByType`]: /functions/resources/byType
### identifier
###### identifier
A string that represents a variable, method, object, or field. It must conform to Go's [language specification](https://go.dev/ref/spec#Identifiers), beginning with a letter or underscore, followed by zero or more letters, digits, or underscores.
### int
###### int
See [integer](#integer).
### integer
###### integer
A numeric data type without a fractional component. For example, `42`.
### internationalization
###### internationalization
Software design and development efforts that enable [localization](#localization). See the [W3C definition](https://www.w3.org/International/questions/qa-i18n). Abbreviated i18n.
### kind
###### kind
See [page kind](#page-kind).
### layout
###### layout
See [template](#template).
### leaf bundle
###### leaf bundle
A [page bundle](#page-bundle) with an index.md file and zero or more [resources](#resource). Analogous to a physical leaf, a leaf bundle is at the end of a branch. Hugo ignores content (but not resources) beneath the leaf bundle. See&nbsp;[details](/content-management/page-bundles/).
### list page
###### list page
Any [page kind](#page-kind) that receives a page [collection](#collection) in [context](#context). This includes the home page, [section pages](#section-page), [taxonomy pages](#taxonomy-page), and [term pages](#term-page).
### localization
###### localization
Adaptation of a site to meet language and regional requirements. This includes translations, language-specific media, date and currency formats, etc. See&nbsp;[details](/content-management/multilingual/) and the [W3C definition](https://www.w3.org/International/questions/qa-i18n). Abbreviated l10n.
### map
###### map
An unordered group of elements, each indexed by a unique key. See the [Go&nbsp;documentation](https://go.dev/ref/spec#Map_types) for details.
### markdown attribute
###### markdown attribute
A list of attributes, containing one or more key/value pairs, separated by spaces or commas, and wrapped by braces. Apply markdown attributes to images and block-level elements including blockquotes, fenced code blocks, headings, horizontal rules, lists, paragraphs, and tables. See&nbsp;[details](/getting-started/configuration-markup/#goldmark).
### marshal
###### marshal
To transform a data structure into a serialized object. For example, transforming a [map](#map) into a JSON string. See [unmarshal](#unmarshal).
### method
###### method
Used within a [template action](#template-action) and associated with an [object](#object), a method takes zero or more [arguments](#argument) and either returns a value or performs an action. For example, `.IsHome` is a method on the `.Page` object which returns `true` if the current page is the home page. See also [function](#function).
### module
###### module
Like a [theme](#theme), a module is a packaged combination of [archetypes](#archetype), assets, content, data, [templates](#template), translation tables, static files, or configuration settings. A module may serve as the basis for a new site, or to augment an existing site. See&nbsp;[details](/hugo-modules/).
### object
###### object
A data structure with or without associated [methods](#method).
### ordered taxonomy
###### ordered taxonomy
Created by invoking the [`Alphabetical`] or [`ByCount`] method on a [taxonomy object](#taxonomy-object), which is a [map](#map), an ordered taxonomy is a [slice](#slice), where each element is an object that contains the [term](#term) and a slice of its [weighted pages](#weighted-page).
[`Alphabetical`]: /methods/taxonomy/alphabetical
[`ByCount`]: /methods/taxonomy/bycount
### output format
###### output format
{{% include "methods/page/_common/output-format-definition.md" %}}
### page bundle
###### page bundle
A directory that encapsulates both content and associated [resources](#resource). There are two types of page bundles: [leaf bundles](#leaf-bundle) and [branch bundles](#branch-bundle). See&nbsp;[details](/content-management/page-bundles/).
### page kind
###### page kind
A classification of pages, one of `home`, `page`, `section`, `taxonomy`, or `term`. See&nbsp;[details](/templates/section-templates/#page-kinds).
Note that there are also `RSS`, `sitemap`, `robotsTXT`, and `404` page kinds, but these are only available during the rendering of each of these respective page's kind and therefore *not* available in any of the `Pages` collections.
### page resource
###### page resource
A file within a [page bundle](#page-bundle). Capture one or more page resources using any of the [`Resources`] methods on a `Page` object.
[`Resources`]: /methods/page/resources/#methods
### pager
###### pager
Created during [pagination](#pagination), a pager contains a subset of a section list, and navigation links to other pagers.
### paginate
###### paginate
To split a [section](#section) list into two or more [pagers](#pager) See&nbsp;[details](/templates/pagination/).
### pagination
###### pagination
The process of [paginating](#paginate) a [section](#section) list.
### parameter
###### parameter
Typically, a user-defined key/value pair at the site or page level, but may also refer to a configuration setting or an [argument](#argument).
### partial
###### partial
A [template](#template) called from any other template including [shortcodes](#shortcode), [render hooks](#render-hook), and other partials. A partial either renders something or returns something. A partial can also call itself, for example, to [walk](#walk) a data structure.
### permalink
###### permalink
The absolute URL of a published resource or a rendered page, including scheme and host.
### pipe
###### pipe
See [pipeline](#pipeline).
### pipeline
###### pipeline
Within a [template action](#template-action), a pipeline is a possibly chained sequence of values, [function](#function) calls, or [method](#method) calls. Functions and methods in the pipeline may take multiple [arguments](#argument).
A pipeline may be *chained* by separating a sequence of commands with pipeline characters "|". In a chained pipeline, the result of each command is passed as the last argument to the following command. The output of the final command in the pipeline is the value of the pipeline. See the [Go&nbsp;documentation](https://pkg.go.dev/text/template#hdr-Pipelines) for details.
### publish
###### publish
See [build](#build).
### regular page
###### regular page
Content with the "page" [page kind](#page-kind). See also [section page](#section-page).
### relative permalink
###### relative permalink
The host-relative URL of a published resource or a rendered page.
### render hook
###### render hook
A [template](#template) that overrides standard markdown rendering. See&nbsp;[details](/templates/render-hooks/).
### remote resource
###### remote resource
A file on a remote server, accessible via HTTP or HTTPS with the [`resources.GetRemote`](/functions/resources/getremote) function.
### resource
###### resource
Any file consumed by the build process to augment or generate content, structure, behavior, or presentation. For example: images, videos, content snippets, CSS, Sass, JavaScript, and data.
Hugo supports three types of resources: [global](#global-resource), [page](#page-resource), and [remote](#remote-resource)
### scalar
###### scalar
A single value, one of [string](#string), [integer](#integer), [floating point](#floating-point), or [boolean](#boolean).
### scratch pad
###### scratch pad
Conceptually, a [map](#map) with [methods](#method) to set, get, update, and delete values. Attach the data structure to a `Page` object using the [`Scratch`] or [`Store`] methods, or created a locally scoped scratch pad using the [`newScratch`] function.
@ -286,86 +285,86 @@ Conceptually, a [map](#map) with [methods](#method) to set, get, update, and del
[`Store`]: /methods/page/store
[`newScratch`]: /functions/collections/newscratch
### section
###### section
A top-level content directory, or any content directory with an&nbsp;_index.md file. A content directory with an&nbsp;_index.md file is also known as a [branch bundle](/getting-started/glossary/#branch-bundle). Section templates receive one or more page [collections](#collection) in [context](#context). See&nbsp;[details](/content-management/sections/).
### section page
###### section page
Content with the "section" [page kind](#page-kind). Typically a listing of [regular pages](#regular-page) and/or [section pages](#section-page) within the current [section](#section). See also [regular page](#regular-page).
### shortcode
###### shortcode
A [template](#template) called from within markdown, taking zero or more [arguments](#argument). See&nbsp;[details](/content-management/shortcodes/).
### slice
###### slice
A numbered sequence of elements. Unlike Go's [array](#array) data type, slices are dynamically sized. [Elements](#element) within a slice can be [scalars](#scalar), [arrays](#array), [maps](#map), pages, or other slices. See the [Go&nbsp;documentation](https://go.dev/ref/spec#Slice_types) for details.
### string
###### string
A sequence of bytes. For example, `"What is 6 times 7?"`&nbsp;.
### taxonomic weight
###### taxonomic weight
Defined in front matter and unique to each taxonomy, this [weight](#weight) determines the sort order of page collections contained within a [taxonomy object](#taxonomy-object). See&nbsp;[details](/templates/taxonomy-templates/#assign-weight).
### taxonomy
###### taxonomy
A group of related [terms](#term) used to classify content. For example, a "colors" taxonomy might include the terms "red", "green", and "blue". See&nbsp;[details](/content-management/taxonomies/).
### taxonomy object
###### taxonomy object
A [map](#map) of [terms](#term) and the [weighted pages](#weighted-page) associated with each term.
### taxonomy page
###### taxonomy page
Content with the "taxonomy" [page kind](#page-kind). Typically a listing of [terms](#term) within a given [taxonomy](#taxonomy).
### template
###### template
A file with [template actions](#template-action), located within the layouts directory of a project, theme, or module. See&nbsp;[details](/templates/).
### template action
###### template action
A data evaluation or control structure within a [template](#template), delimited by "{{"&nbsp;and&nbsp;"}}". See the [Go&nbsp;documentation](https://pkg.go.dev/text/template#hdr-Actions) for details.
### term
###### term
A member of a [taxonomy](#taxonomy), used to classify content. See&nbsp;[details](/content-management/taxonomies/).
### term page
###### term page
Content with the "term" [page kind](#page-kind). Typically a listing of [regular pages](#regular-page) and [section pages](#section-page) with a given [term](#term).
### theme
###### theme
A packaged combination of [archetypes](#archetype), assets, content, data, [templates](#template), translation tables, static files, or configuration settings. A theme may serve as the basis for a new site, or to augment an existing site. See also [module](#module).
### token
###### token
An identifier within a format string, beginning with a colon and replaced with a value when rendered. For example, use tokens in format strings for both [permalinks](/content-management/urls/#permalinks) and [dates](/functions/time/format/#localization).
### type
###### type
See [content type](#content-type).
### unmarshal
###### unmarshal
To transform a serialized object into a data structure. For example, transforming a JSON file into a [map](#map) that you can access within a template. See [marshal](#marshal).
### variable
###### variable
A user-defined [identifier](#identifier) prefaced with a `$` symbol, representing a value of any data type, initialized or assigned within a [template action](#template-action). For example, `$foo`&nbsp;and&nbsp;`$bar` are variables.
### walk
###### walk
To recursively traverse a nested data structure. For example, rendering a multilevel menu.
### weight
###### weight
Used to position an element within a collection sorted by weight. Assign weights using non-zero integers. Lighter items float to the top, while heavier items sink to the bottom. Unweighted or zero-weighted elements are placed at the end of the collection. Weights are typically assigned to pages, menu entries, languages, and output formats.
### weighted page
###### weighted page
Contained within a [taxonomy object](#taxonomy-object), a weighted page is a [map](#map) with two elements: a `Page` object, and its [taxonomic weight](#taxonomic-weight) as defined in front matter. Access the elements using the `Page` and `Weight` keys.

2
go.mod
View File

@ -2,4 +2,4 @@ module github.com/gohugoio/hugoDocs
go 1.16
require github.com/gohugoio/gohugoioTheme v0.0.0-20231109022943-a05c967b35f8 // indirect
require github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e // indirect

4
go.sum
View File

@ -1,2 +1,2 @@
github.com/gohugoio/gohugoioTheme v0.0.0-20231109022943-a05c967b35f8 h1:HXgjBdZt+bMvx9nlrJF9qgFNpT2T9tgJ8rwWRqF9MWw=
github.com/gohugoio/gohugoioTheme v0.0.0-20231109022943-a05c967b35f8/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM=
github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e h1:X4OxWNt7weGfmRHBAQWW1gsdZBd3V/6DJMNhrYS9ALE=
github.com/gohugoio/gohugoioTheme v0.0.0-20231111235806-77931ac4875e/go.mod h1:GOYeAPQJ/ok8z7oz1cjfcSlsFpXrmx6VkzQ5RpnyhZM=

View File

@ -1,101 +0,0 @@
{{- /*
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
@param {string} [config] The section of site.Data.docs.config to render.
@param {bool} [copy=false] If true, display a copy to clipboard button.
@param {string} [file] The file name to display above the rendered code.
@param {bool} [fm=false] If true, render the code as front matter.
@param {bool} [skipHeader=false] If false, omit top level key(s) when rendering a section of site.Data.docs.config.
@returns {template.HTML}
*/}}
{{- /* Initialize. */}}
{{- $config := "" }}
{{- $dataKey := "" }}
{{- $copy := false }}
{{- $file := "" }}
{{- $fm := false }}
{{- $skipHeader := false }}
{{- /* Get parameters. */}}
{{- $config = .Get "config" }}
{{- $dataKey = .Get "dataKey" }}
{{- $file = .Get "file" }}
{{- if in (slice "false" false 0) (.Get "copy") }}
{{- $copy = false }}
{{- else if in (slice "true" true 1) (.Get "copy") }}
{{- $copy = true }}
{{- end }}
{{- if in (slice "false" false 0) (.Get "fm") }}
{{- $fm = false }}
{{- else if in (slice "true" true 1) (.Get "fm") }}
{{- $fm = true }}
{{- end }}
{{- if in (slice "false" false 0) (.Get "skipHeader") }}
{{- $skipHeader = false }}
{{- else if in (slice "true" true 1) (.Get "skipHeader") }}
{{- $skipHeader = true }}
{{- end }}
{{- /* Define constants. */}}
{{- $delimiters := dict "toml" "+++" "yaml" "---" }}
{{- $langs := slice "yaml" "toml" "json" }}
{{- $placeHolder := "#-hugo-placeholder-#" }}
{{- /* Render. */}}
{{- $code := "" }}
{{- if $config }}
{{- $file = $file | default "hugo" }}
{{- $sections := (split $config ".") }}
{{- $configSection := index $.Site.Data.docs.config $sections }}
{{- $code = dict $sections $configSection }}
{{- if $skipHeader }}
{{- $code = $configSection }}
{{- end }}
{{- else if $dataKey }}
{{- $file = $file | default $dataKey }}
{{- $sections := (split $dataKey ".") }}
{{- $code = index $.Site.Data.docs $sections }}
{{- else }}
{{- $code = $.Inner }}
{{- end }}
<div class="code relative" {{ with $file }}id="{{ . | urlize }}"{{ end }}>
<div class="code-nav flex flex-nowrap items-stretch">
{{- with $file }}
<div class="san-serif f6 dib lh-solid pl2 pv2 mr2">
{{ . }}{{ if not $fm }}.{{ end }}
</div>
{{- end }}
{{- range $langs }}
<button
data-toggle-tab="{{ . }}"
class="tab-button {{ cond (eq . "yaml") "active" "" }} ba san-serif f6 dib lh-solid ph2 pv2">
{{ . }}
</button>
&nbsp;
{{- end }}
</div>
<div class="tab-content">
{{- range $langs }}
<div
data-pane="{{ . }}"
class="code-copy-content nt3 tab-pane {{ cond (eq . "yaml") "active" "" }}">
{{- $hCode := $code | transform.Remarshal . }}
{{- if and $fm (in (slice "toml" "yaml") .) }}
{{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }}
{{- end }}
{{- $hCode = $hCode | replaceRE `\n+` "\n" }}
{{ highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
</div>
{{- if $copy }}
<button
class="needs-js copy copy-toggle bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2"
title="Copy this code to your clipboard."
data-clipboard-action="copy"
aria-label="copy button"></button>
{{- /* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}}
{{- end }}
{{- end }}
</div>
</div>

View File

@ -1,35 +0,0 @@
{{- /*
Renders syntax highlighted code.
@param {bool} [copy=false] If true, display a copy to clipboard button.
@param {string} [file] The file name to display above the rendered code.
@param {string} [lang] The code language of the inner content.
@returns {template.HTML}
*/}}
{{- /* Get parameters. */}}
{{- $copy := false }}
{{- if in (slice "false" false 0) (.Get "copy") }}
{{- $copy = false }}
{{- else if in (slice "true" true 1) (.Get "copy")}}
{{- $copy = true }}
{{- end }}
{{- $file := or (.Get "file") "&nbsp;" }}
{{- $lang := or (.Get "lang") (path.Ext $file | strings.TrimPrefix ".") "text" }}
{{- /* Use the go-html-template Chroma lexer for HTML. */}}
{{- if eq $lang "html" }}
{{- $lang = "go-html-template" }}
{{- end }}
{{- /* Render. */}}
<div class="code relative" id="{{ $file | urlize }}">
<div class="f6 dib lh-solid pl2 pv2">{{ $file | htmlUnescape }}</div>
{{- if $copy }}
<button class="needs-js copy bg-accent-color-dark f6 absolute top-0 right-0 lh-solid hover-bg-primary-color-dark bn white ph3 pv2" title="Copy this code to your clipboard." data-clipboard-action="copy" aria-label="copy button"></button>
{{- end }}
<div class="code-copy-content nt3">
{{- highlight (trim .Inner "\n\r") $lang }}
</div>
</div>

View File

@ -1,374 +0,0 @@
{{- /*
Renders the given image using the given filter, if any.
@param {string} src The path to the image which must be a remote, page, or global resource.
@param {string} [filter] The filter to apply to the image (case-insensitive).
@param {string} [filterArgs] A comma-delimited list of arguments to pass to the filter.
@param {bool} [example=false] If true, renders a before/after example.
@param {int} [exampleWidth=384] Image width, in pixels, when rendering a before/after example.
@returns {template.HTML}
@examples
{{< img src="zion-national-park.jpg" >}}
{{< img src="zion-national-park.jpg" alt="Zion National Park" >}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="process"
filterArgs="resize 400x webp"
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="colorize"
filterArgs="180,50,20"
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
example=true
>}}
{{< img
src="zion-national-park.jpg"
alt="Zion National Park"
filter="grayscale"
example=true
exampleWidth=400
>}}
When using the text filter, provide the arguments in this order:
0. The text
1. The horizontal offset, in pixels, relative to the left of the image (default 20)
2. The vertical offset, in pixels, relative to the top of the image (default 20)
3. The font size in pixels (default 64)
4. The line height (default 1.2)
5. The font color (default #ffffff)
{{< img
src="images/examples/zion-national-park.jpg"
alt="Zion National Park"
filter="Text"
filterArgs="Zion National Park,25,250,56"
example=true
>}}
When using the padding filter, provide all arguments in this order:
0. Padding top
1. Padding right
2. Padding bottom
3. Padding right
4. Canvas color
{{< img
src="images/examples/zion-national-park.jpg"
alt="Zion National Park"
filter="Padding"
filterArgs="20,50,20,50,#0705"
example=true
>}}
*/}}
{{- /* Initialize. */}}
{{- $alt := "" }}
{{- $src := "" }}
{{- $filter := "" }}
{{- $filterArgs := slice }}
{{- $example := false }}
{{- $exampleWidth := 384 }}
{{- /* Default values to use with the text filter. */}}
{{ $textFilterOpts := dict
"xOffset" 20
"yOffset" 20
"fontSize" 64
"lineHeight" 1.2
"fontColor" "#ffffff"
"fontPath" "https://github.com/google/fonts/raw/main/apache/roboto/static/Roboto-Regular.ttf"
}}
{{- /* Get and validate parameters. */}}
{{- with .Get "alt" }}
{{- $alt = .}}
{{- end }}
{{- with .Get "src" }}
{{- $src = . }}
{{- else }}
{{- errorf "The %q shortcode requires a file parameter. See %s" .Name .Position }}
{{- end }}
{{- with .Get "filter" }}
{{- $filter = . | lower }}
{{- end }}
{{- $validFilters := slice
"brightness" "colorbalance" "colorize" "contrast" "gamma" "gaussianblur"
"grayscale" "hue" "invert" "none" "opacity" "overlay" "padding" "pixelate"
"process" "saturation" "sepia" "sigmoid" "text" "unsharpmask"
}}
{{- with $filter }}
{{- if not (in $validFilters .) }}
{{- errorf "The filter passed to the %q shortcode is invalid. The filter must be one of %s. See %s" $.Name (delimit $validFilters ", " ", or ") $.Position }}
{{- end }}
{{- end }}
{{- with .Get "filterArgs" }}
{{- $filterArgs = split . "," }}
{{- $filterArgs = apply $filterArgs "trim" "." " " }}
{{- end }}
{{- if in (slice "false" false 0) (.Get "example") }}
{{- $example = false }}
{{- else if in (slice "true" true 1) (.Get "example")}}
{{- $example = true }}
{{- end }}
{{- with .Get "exampleWidth" }}
{{- $exampleWidth = . | int }}
{{- end }}
{{- /* Get image. */}}
{{- $ctx := dict "page" .Page "src" $src "name" .Name "position" .Position }}
{{- $i := partial "inline/get-resource.html" $ctx }}
{{- /* Resize if rendering before/after examples. */}}
{{- if $example }}
{{- $i = $i.Resize (printf "%dx" $exampleWidth) }}
{{- end }}
{{- /* Create filter. */}}
{{- $f := "" }}
{{- $ctx := dict "filter" $filter "args" $filterArgs "name" .Name "position" .Position }}
{{- if eq $filter "brightness" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Brightness (index $filterArgs 0) }}
{{- else if eq $filter "colorbalance" }}
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "percentage red" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "percentage green" "argValue" (index $filterArgs 1) "min" -100 "max" 500) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "percentage blue" "argValue" (index $filterArgs 2) "min" -100 "max" 500) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.ColorBalance (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }}
{{- else if eq $filter "colorize" }}
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "hue" "argValue" (index $filterArgs 0) "min" 0 "max" 360) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "saturation" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 2) "min" 0 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Colorize (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }}
{{- else if eq $filter "contrast" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Contrast (index $filterArgs 0) }}
{{- else if eq $filter "gamma" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "gamma" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Gamma (index $filterArgs 0) }}
{{- else if eq $filter "gaussianblur" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.GaussianBlur (index $filterArgs 0) }}
{{- else if eq $filter "grayscale" }}
{{- $ctx = merge $ctx (dict "argsRequired" 0) }}
{{- template "validate-arg-count" $ctx }}
{{- $f = images.Grayscale }}
{{- else if eq $filter "hue" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "shift" "argValue" (index $filterArgs 0) "min" -180 "max" 180) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Hue (index $filterArgs 0) }}
{{- else if eq $filter "invert" }}
{{- $ctx = merge $ctx (dict "argsRequired" 0) }}
{{- template "validate-arg-count" $ctx }}
{{- $f = images.Invert }}
{{- else if eq $filter "opacity" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "opacity" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Opacity (index $filterArgs 0) }}
{{- else if eq $filter "overlay" }}
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
{{- template "validate-arg-count" $ctx }}
{{- $ctx := dict "src" (index $filterArgs 0) "name" .Name "position" .Position }}
{{- $overlayImg := partial "inline/get-resource.html" $ctx }}
{{- $f = images.Overlay $overlayImg (index $filterArgs 1 | float ) (index $filterArgs 2 | float) }}
{{- else if eq $filter "padding" }}
{{- $ctx = merge $ctx (dict "argsRequired" 5) }}
{{- template "validate-arg-count" $ctx }}
{{- $f = images.Padding
(index $filterArgs 0 | int)
(index $filterArgs 1 | int)
(index $filterArgs 2 | int)
(index $filterArgs 3 | int)
(index $filterArgs 4)
}}
{{- else if eq $filter "pixelate" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "size" "argValue" (index $filterArgs 0) "min" 0 "max" 1000) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Pixelate (index $filterArgs 0) }}
{{- else if eq $filter "process" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $f = images.Process (index $filterArgs 0) }}
{{- else if eq $filter "saturation" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" -100 "max" 500) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Saturation (index $filterArgs 0) }}
{{- else if eq $filter "sepia" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "percentage" "argValue" (index $filterArgs 0) "min" 0 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Sepia (index $filterArgs 0) }}
{{- else if eq $filter "sigmoid" }}
{{- $ctx = merge $ctx (dict "argsRequired" 2) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "midpoint" "argValue" (index $filterArgs 0) "min" 0 "max" 1) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "factor" "argValue" (index $filterArgs 1) "min" -10 "max" 10) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.Sigmoid (index $filterArgs 0) (index $filterArgs 1) }}
{{- else if eq $filter "text" }}
{{- $ctx = merge $ctx (dict "argsRequired" 1) }}
{{- template "validate-arg-count" $ctx }}
{{- $ctx := dict "src" $textFilterOpts.fontPath "name" .Name "position" .Position }}
{{- $font := or (partial "inline/get-resource.html" $ctx) }}
{{- $fontSize := or (index $filterArgs 3 | int) $textFilterOpts.fontSize }}
{{- $lineHeight := math.Max (or (index $filterArgs 4 | float) $textFilterOpts.lineHeight) 1 }}
{{- $opts := dict
"x" (or (index $filterArgs 1 | int) $textFilterOpts.xOffset)
"y" (or (index $filterArgs 2 | int) $textFilterOpts.yOffset)
"size" $fontSize
"linespacing" (mul (sub $lineHeight 1) $fontSize)
"color" (or (index $filterArgs 5) $textFilterOpts.fontColor)
"font" $font
}}
{{- $f = images.Text (index $filterArgs 0) $opts }}
{{- else if eq $filter "unsharpmask" }}
{{- $ctx = merge $ctx (dict "argsRequired" 3) }}
{{- template "validate-arg-count" $ctx }}
{{- $filterArgs = apply $filterArgs "float" "." }}
{{- $ctx = merge $ctx (dict "argName" "sigma" "argValue" (index $filterArgs 0) "min" 0 "max" 500) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "amount" "argValue" (index $filterArgs 1) "min" 0 "max" 100) }}
{{- template "validate-arg-value" $ctx }}
{{- $ctx = merge $ctx (dict "argName" "threshold" "argValue" (index $filterArgs 2) "min" 0 "max" 1) }}
{{- template "validate-arg-value" $ctx }}
{{- $f = images.UnsharpMask (index $filterArgs 0) (index $filterArgs 1) (index $filterArgs 2) }}
{{- end }}
{{- /* Apply filter. */}}
{{- $fi := $i }}
{{- with $f }}
{{- $fi = $i.Filter . }}
{{- end }}
{{- /* Render. */}}
{{- if $example }}
<p>Original</p>
<img class='di ba b--black-20' style="width: initial;" src="{{ $i.RelPermalink }}" alt="{{ $alt }}">
<p>Processed</p>
<img class='di ba b--black-20' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
{{- else -}}
<img class='di' style="width: initial;" src="{{ $fi.RelPermalink }}" alt="{{ $alt }}">
{{- end }}
{{- define "validate-arg-count" }}
{{- $msg := "When using the %q filter, the %q shortcode requires an args parameter with %d %s. See %s" }}
{{- if lt (len .args) .argsRequired }}
{{- $text := "values" }}
{{- if eq 1 .argsRequired }}
{{- $text = "value" }}
{{- end }}
{{- errorf $msg .filter .name .argsRequired $text .position }}
{{- end }}
{{- end }}
{{- define "validate-arg-value" }}
{{- $msg := "The %q argument passed to the %q shortcode is invalid. Expected a value in the range [%v,%v], but received %v. See %s" }}
{{- if or (lt .argValue .min) (gt .argValue .max) }}
{{- errorf $msg .argName .name .min .max .argValue .position }}
{{- end }}
{{- end }}
{{- define "partials/inline/get-resource.html" }}
{{- $r := "" }}
{{- $u := urls.Parse .src }}
{{- $msg := "The %q shortcode was unable to resolve %s. See %s" }}
{{- if $u.IsAbs }}
{{- with resources.GetRemote $u.String }}
{{- with .Err }}
{{- errorf "%s" }}
{{- else }}
{{- /* This is a remote resource. */}}
{{- $r = . }}
{{- end }}
{{- else }}
{{- errorf $msg $.name $u.String $.position }}
{{- end }}
{{- else }}
{{- with .page.Resources.Get (strings.TrimPrefix "./" $u.Path) }}
{{- /* This is a page resource. */}}
{{- $r = . }}
{{- else }}
{{- with resources.Get $u.Path }}
{{- /* This is a global resource. */}}
{{- $r = . }}
{{- else }}
{{- errorf $msg $.name $u.Path $.position }}
{{- end }}
{{- end }}
{{- end }}
{{- return $r}}
{{- end -}}

View File

@ -1,37 +0,0 @@
{{- /*
Renders the given image using the given process specification.
@param {string} (positional parameter 0) The path to the image, relative to the current page. The image must be a page resource.
@param {string}} (positional parameter 1) The image processing specification.
@returns template.HTML
@example {{< imgproc "sunset.jpg" "resize 300x" />}}
*/}}
{{- with $.Get 0 }}
{{- with $i := $.Page.Resources.Get . }}
{{- with $spec := $.Get 1 }}
{{- with $i.Process . }}
<figure style="padding: 0.25rem; margin: 2rem 0; background-color: #cccc">
<img style="max-width: 100%; width: auto; height: auto;" src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
<figcaption>
<small>
{{- with $.Inner }}
{{ . }}
{{- else }}
{{ $spec }}
{{- end }}
</small>
</figcaption>
</figure>
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a positional parameter (1) containing the image processing specification. See %s" $.Name $.Position }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a positional parameter (0) indicating the image path, relative to the current page. See %s" $.Name $.Position }}
{{- end }}

View File

@ -1,13 +0,0 @@
{{ $version := .Get 0 }}
{{ if not $version }}
{{ errorf "Missing version in new-in shortcode " }}
{{ end }}
{{ $version = $version | strings.TrimPrefix "v" }}
<button
class="bg-white hover:bg-gray-100 text-gray-800 font-semibold py-2 mr2 px-4 border border-gray-400 rounded shadow">
<a
href="{{ printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }}"
target="_blank"
>New in v{{ $version }}</a
>
</button>

View File

@ -1,7 +0,0 @@
{{ $_hugo_config := `{ "version": 1 }` }}
<aside>
<div class="admonition-content bl bw2 b--blue" >
{{ .Inner }}
</div>
</aside>