Remove superfluous shortcode param

This commit is contained in:
Joe Mooring authored and Joe Mooring committed 2023-11-07 14:06:01 -08:00
1 parent 2a0544757c
commit 45ec53fe00
27 files changed
+49 -49

No files matched your search

+4 -4
View File
@@ -49,7 +49,7 @@ In addition to using a single site configuration file, one can use the `configDi
foo = "bar" foo = "bar"
{{< /code-toggle >}} {{< /code-toggle >}}
{{< code-toggle file="params" copy=false >}} {{< code-toggle file="params" >}}
foo = "bar" foo = "bar"
{{< /code-toggle >}} {{< /code-toggle >}}
@@ -78,7 +78,7 @@ Let's take an example to understand this better. Let's say you are using Google
[Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en [Google tag ID]: https://support.google.com/tagmanager/answer/12326985?hl=en
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[services.googleAnalytics] [services.googleAnalytics]
ID = 'G-XXXXXXXXX' ID = 'G-XXXXXXXXX'
{{< /code-toggle >}} {{< /code-toggle >}}
@@ -103,7 +103,7 @@ To satisfy these requirements, configure your site as follows:
Include this section only: Include this section only:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[services.googleAnalytics] [services.googleAnalytics]
ID = 'G-PPPPPPPPP' ID = 'G-PPPPPPPPP'
{{< /code-toggle >}} {{< /code-toggle >}}
@@ -116,7 +116,7 @@ To satisfy these requirements, configure your site as follows:
Include this section only: Include this section only:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[services.googleAnalytics] [services.googleAnalytics]
ID = 'G-SSSSSSSSS' ID = 'G-SSSSSSSSS'
{{< /code-toggle >}} {{< /code-toggle >}}
+1 -1
View File
@@ -14,7 +14,7 @@ Use the `Children` method when rendering a nested menu.
With this site configuration: With this site configuration:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
name = 'Products' name = 'Products'
pageRef = '/product' pageRef = '/product'
+1 -1
View File
@@ -14,7 +14,7 @@ Use the `HasChildren` method when rendering a nested menu.
With this site configuration: With this site configuration:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
name = 'Products' name = 'Products'
pageRef = '/product' pageRef = '/product'
+1 -1
View File
@@ -13,7 +13,7 @@ The `Identifier` method returns the `identifier` property of the menu entry. If
[automatically]: /content-management/menus/#define-automatically [automatically]: /content-management/menus/#define-automatically
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
identifier = 'about' identifier = 'about'
name = 'About' name = 'About'
+1 -1
View File
@@ -11,7 +11,7 @@ action:
In this menu definition, the second entry does not contain an `identifier`, so the `Identifier` method returns its `name` property instead: In this menu definition, the second entry does not contain an `identifier`, so the `Identifier` method returns its `name` property instead:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
identifier = 'about' identifier = 'about'
name = 'About' name = 'About'
+1 -1
View File
@@ -13,7 +13,7 @@ Regardless of how you [define menu entries], an entry associated with a page has
In this menu definition, the first two entries are associated with a page, the last entry is not: In this menu definition, the first two entries are associated with a page, the last entry is not:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
pageRef = '/about' pageRef = '/about'
weight = 10 weight = 10
+1 -1
View File
@@ -11,7 +11,7 @@ action:
When you define menu entries [in site configuration] or [in front matter], you can include a `params` key to attach additional information to the entry. For example: When you define menu entries [in site configuration] or [in front matter], you can include a `params` key to attach additional information to the entry. For example:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
name = 'About' name = 'About'
pageRef = '/about' pageRef = '/about'
+1 -1
View File
@@ -11,7 +11,7 @@ action:
With this menu definition: With this menu definition:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[menu] [menu]
[[menu.main]] [[menu.main]]
name = 'Products' name = 'Products'
@@ -4,7 +4,7 @@
In this site configuration we enable rendering of [emoji shortcodes], and add emoji shortcodes before (pre) and after (post) each menu entry: In this site configuration we enable rendering of [emoji shortcodes], and add emoji shortcodes before (pre) and after (post) each menu entry:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
enableEmoji = true enableEmoji = true
[[menu.main]] [[menu.main]]
+1 -1
View File
@@ -13,7 +13,7 @@ The `Sort` method returns the given menu with its entries sorted by `name`.
Consider this menu definition: Consider this menu definition:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
name = 'Services' name = 'Services'
pageRef = '/services' pageRef = '/services'
+1 -1
View File
@@ -15,7 +15,7 @@ The `ByWeight` method returns the given menu with its entries sorted by [`weight
Consider this menu definition: Consider this menu definition:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
identifier = 'about' identifier = 'about'
name = 'About' name = 'About'
+1 -1
View File
@@ -13,7 +13,7 @@ The `Limit` method returns the given menu, limited to the first N entries.
Consider this menu definition: Consider this menu definition:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
name = 'Services' name = 'Services'
pageRef = '/services' pageRef = '/services'
+1 -1
View File
@@ -13,7 +13,7 @@ The `Reverse` method returns the given menu, reversing the sort order of its ent
Consider this menu definition: Consider this menu definition:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[[menu.main]] [[menu.main]]
name = 'Services' name = 'Services'
pageRef = '/services' pageRef = '/services'
+2 -2
View File
@@ -15,7 +15,7 @@ Based on front matter, Hugo uses several factors to identify content related to
The argument passed to the `Related` method may be a `Page` or an options map. For example, to pass the current page: The argument passed to the `Related` method may be a `Page` or an options map. For example, to pass the current page:
{{< code file="layouts/_default/single.html" lang=go-html-template copy=false >}} {{< code file="layouts/_default/single.html" lang=go-html-template >}}
{{ with .Site.RegularPages.Related . | first 5 }} {{ with .Site.RegularPages.Related . | first 5 }}
<p>Related pages:</p> <p>Related pages:</p>
<ul> <ul>
@@ -28,7 +28,7 @@ The argument passed to the `Related` method may be a `Page` or an options map. F
To pass an options map: To pass an options map:
{{< code file="layouts/_default/single.html" lang=go-html-template copy=false >}} {{< code file="layouts/_default/single.html" lang=go-html-template >}}
{{ $opts := dict {{ $opts := dict
"document" . "document" .
"indices" (slice "tags" "keywords") "indices" (slice "tags" "keywords")
+1 -1
View File
@@ -14,7 +14,7 @@ action:
By way of example, consider this site configuration: By way of example, consider this site configuration:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
baseURL = 'https://example.org/docs/' baseURL = 'https://example.org/docs/'
{{< /code-toggle >}} {{< /code-toggle >}}
+1 -1
View File
@@ -30,7 +30,7 @@ content/
And this front matter: And this front matter:
{{< code-toggle file=content/posts/cats.md fm=true copy=false >}} {{< code-toggle file=content/posts/cats.md fm=true >}}
title = 'Cats' title = 'Cats'
[[resources]] [[resources]]
src = 'images/a.jpg' src = 'images/a.jpg'
+1 -1
View File
@@ -34,7 +34,7 @@ content/
With the structure above, we can range through page resources of type `page` to build content: With the structure above, we can range through page resources of type `page` to build content:
{{< code file="layouts/lessons/single.html" lang=go-html-template copy=false >}} {{< code file="layouts/lessons/single.html" lang=go-html-template >}}
{{ range .Resources.ByType "page" }} {{ range .Resources.ByType "page" }}
{{ .Content }} {{ .Content }}
{{ end }} {{ end }}
+4 -4
View File
@@ -22,13 +22,13 @@ Some shortcodes support positional parameters, some support named parameters, an
This shortcode call uses positional parameters: This shortcode call uses positional parameters:
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
{{</* myshortcode "Hello" "world" */>}} {{</* myshortcode "Hello" "world" */>}}
{{< /code >}} {{< /code >}}
To retrieve parameters by position: To retrieve parameters by position:
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world. {{ printf "%s %s." (.Get 0) (.Get 1) }} → Hello world.
{{< /code >}} {{< /code >}}
@@ -36,13 +36,13 @@ To retrieve parameters by position:
This shortcode call uses named parameters: This shortcode call uses named parameters:
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
{{</* myshortcode greeting="Hello" firstName="world" */>}} {{</* myshortcode greeting="Hello" firstName="world" */>}}
{{< /code >}} {{< /code >}}
To retrieve parameters by name: To retrieve parameters by name:
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world. {{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} → Hello world.
{{< /code >}} {{< /code >}}
+6 -6
View File
@@ -15,7 +15,7 @@ action:
This content: This content:
{{< code file="content/services.md" lang=md copy=false >}} {{< code file="content/services.md" lang=md >}}
{{</* card title="Product Design" */>}} {{</* card title="Product Design" */>}}
We design the **best** widgets in the world. We design the **best** widgets in the world.
{{</* /card */>}} {{</* /card */>}}
@@ -23,7 +23,7 @@ We design the **best** widgets in the world.
With this shortcode: With this shortcode:
{{< code file="layouts/shortcodes/card.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/card.html" lang=go-html-template >}}
<div class="card"> <div class="card">
{{ with .Get "title" }} {{ with .Get "title" }}
<div class="card-title">{{ . }}</div> <div class="card-title">{{ . }}</div>
@@ -62,7 +62,7 @@ Let's modify the example above to pass the value returned by `Inner` through the
[`RenderString`]: /methods/page/renderstring [`RenderString`]: /methods/page/renderstring
{{< code file="layouts/shortcodes/card.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/card.html" lang=go-html-template >}}
<div class="card"> <div class="card">
{{ with .Get "title" }} {{ with .Get "title" }}
<div class="card-title">{{ . }}</div> <div class="card-title">{{ . }}</div>
@@ -93,7 +93,7 @@ You can use the [`markdownify`] function instead of the `RenderString` method, b
Instead of calling the shortcode with the `{{</* */>}}` notation, use the `{{%/* */%}}` notation: Instead of calling the shortcode with the `{{</* */>}}` notation, use the `{{%/* */%}}` notation:
{{< code file="content/services.md" lang=md copy=false >}} {{< code file="content/services.md" lang=md >}}
{{%/* card title="Product Design" */%}} {{%/* card title="Product Design" */%}}
We design the **best** widgets in the world. We design the **best** widgets in the world.
{{%/* /card */%}} {{%/* /card */%}}
@@ -103,7 +103,7 @@ When you use the `{{%/* */%}}` notation, Hugo renders the entire shortcode as ma
First, configure the renderer to allow raw HTML within markdown: First, configure the renderer to allow raw HTML within markdown:
{{< code-toggle file=hugo copy=false >}} {{< code-toggle file=hugo >}}
[markup.goldmark.renderer] [markup.goldmark.renderer]
unsafe = true unsafe = true
{{< /code-toggle >}} {{< /code-toggle >}}
@@ -112,7 +112,7 @@ This configuration is not unsafe if _you_ control the content. Read more about H
Second, because we are rendering the entire shortcode as markdown, we must adhere to the rules governing [indentation] and inclusion of [raw HTML blocks] as provided in the [CommonMark] specification. Second, because we are rendering the entire shortcode as markdown, we must adhere to the rules governing [indentation] and inclusion of [raw HTML blocks] as provided in the [CommonMark] specification.
{{< code file="layouts/shortcodes/card.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/card.html" lang=go-html-template >}}
<div class="card"> <div class="card">
{{ with .Get "title" }} {{ with .Get "title" }}
<div class="card-title">{{ . }}</div> <div class="card-title">{{ . }}</div>
@@ -16,7 +16,7 @@ This allows us to effectively bypass the rules governing [indentation] as provid
Consider this markdown, an unordered list with a small gallery of thumbnail images within each list item: Consider this markdown, an unordered list with a small gallery of thumbnail images within each list item:
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
- Gallery one - Gallery one
{{</* gallery */>}} {{</* gallery */>}}
@@ -36,7 +36,7 @@ In the example above, notice that the content between the opening and closing sh
With this shortcode, calling `Inner` instead of `InnerDeindent`: With this shortcode, calling `Inner` instead of `InnerDeindent`:
{{< code file="layouts/shortcodes/gallery.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/gallery.html" lang=go-html-template >}}
<div class="gallery"> <div class="gallery">
{{ trim .Inner "\r\n" | .Page.RenderString }} {{ trim .Inner "\r\n" | .Page.RenderString }}
</div> </div>
@@ -67,7 +67,7 @@ Hugo renders the markdown to:
Although technically correct per the CommonMark specification, this is not what we want. If we remove the indentation using the `InnerDeindent` method: Although technically correct per the CommonMark specification, this is not what we want. If we remove the indentation using the `InnerDeindent` method:
{{< code file="layouts/shortcodes/gallery.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/gallery.html" lang=go-html-template >}}
<div class="gallery"> <div class="gallery">
{{ trim .InnerDeindent "\r\n" | .Page.RenderString }} {{ trim .InnerDeindent "\r\n" | .Page.RenderString }}
</div> </div>
@@ -14,7 +14,7 @@ To support both positional and named parameters when calling a shortcode, use th
With this shortcode template: With this shortcode template:
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ if .IsNamedParams }} {{ if .IsNamedParams }}
{{ printf "%s %s." (.Get "greeting") (.Get "firstName") }} {{ printf "%s %s." (.Get "greeting") (.Get "firstName") }}
{{ else }} {{ else }}
@@ -24,7 +24,7 @@ With this shortcode template:
Both of these calls return the same value: Both of these calls return the same value:
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
{{</* myshortcode greeting="Hello" firstName="world" */>}} {{</* myshortcode greeting="Hello" firstName="world" */>}}
{{</* myshortcode "Hello" "world" */>}} {{</* myshortcode "Hello" "world" */>}}
{{< /code >}} {{< /code >}}
+1 -1
View File
@@ -13,7 +13,7 @@ action:
The `Name` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter: The `Name` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter:
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ $greeting := "" }} {{ $greeting := "" }}
{{ with .Get "greeting" }} {{ with .Get "greeting" }}
{{ $greeting = . }} {{ $greeting = . }}
+2 -2
View File
@@ -13,7 +13,7 @@ The `Ordinal` method returns the zero-based ordinal of the shortcode in relation
This method is useful for, among other things, assigning unique element IDs when a shortcode is called two or more times from the same page. For example: This method is useful for, among other things, assigning unique element IDs when a shortcode is called two or more times from the same page. For example:
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
{{</* img src="images/a.jpg" */>}} {{</* img src="images/a.jpg" */>}}
{{</* img src="images/b.jpg" */>}} {{</* img src="images/b.jpg" */>}}
@@ -21,7 +21,7 @@ This method is useful for, among other things, assigning unique element IDs when
This shortcode performs error checking, then renders an HTML `img` element with a unique `id` attribute: This shortcode performs error checking, then renders an HTML `img` element with a unique `id` attribute:
{{< code file="layouts/shortcodes/img.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/img.html" lang=go-html-template >}}
{{ $src := "" }} {{ $src := "" }}
{{ with .Get "src" }} {{ with .Get "src" }}
{{ $src = . }} {{ $src = . }}
+2 -2
View File
@@ -11,7 +11,7 @@ action:
With this content: With this content:
{{< code-toggle file=content/books/les-miserables.md copy=false fm=true >}} {{< code-toggle file=content/books/les-miserables.md fm=true >}}
title = 'Les Misérables' title = 'Les Misérables'
author = 'Victor Hugo' author = 'Victor Hugo'
published = 1862 published = 1862
@@ -26,7 +26,7 @@ Calling this shortcode:
We can access the front matter values using the `Page` method: We can access the front matter values using the `Page` method:
{{< code file="layouts/shortcodes/book-details.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/book-details.html" lang=go-html-template >}}
<ul> <ul>
<li>Title: {{ .Page.Title }}</li> <li>Title: {{ .Page.Title }}</li>
<li>Author: {{ .Page.Params.author }}</li> <li>Author: {{ .Page.Params.author }}</li>
+4 -4
View File
@@ -12,22 +12,22 @@ action:
When you call a shortcode using positional parameters, the `Params` method returns a slice. When you call a shortcode using positional parameters, the `Params` method returns a slice.
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
{{</* myshortcode "Hello" "world" */>}} {{</* myshortcode "Hello" "world" */>}}
{{< /code >}} {{< /code >}}
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ index .Params 0 }} → Hello {{ index .Params 0 }} → Hello
{{ index .Params 1 }} → world {{ index .Params 1 }} → world
{{< /code >}} {{< /code >}}
When you call a shortcode using named parameters, the `Params` method returns a map. When you call a shortcode using named parameters, the `Params` method returns a map.
{{< code file="content/about.md" lang=md copy=false >}} {{< code file="content/about.md" lang=md >}}
{{</* myshortcode greeting="Hello" name="world" */>}} {{</* myshortcode greeting="Hello" name="world" */>}}
{{< /code >}} {{< /code >}}
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ .Params.greeting }} → Hello {{ .Params.greeting }} → Hello
{{ .Params.name }} → world {{ .Params.name }} → world
{{< /code >}} {{< /code >}}
+3 -3
View File
@@ -13,19 +13,19 @@ This is useful for inheritance of common shortcode parameters from the root.
In this contrived example, the "greeting" shortcode is the parent, and the "now" shortcode is child. In this contrived example, the "greeting" shortcode is the parent, and the "now" shortcode is child.
{{< code file="content/welcome.md" lang=md copy=false >}} {{< code file="content/welcome.md" lang=md >}}
{{</* greeting dateFormat="Jan 2, 2006" */>}} {{</* greeting dateFormat="Jan 2, 2006" */>}}
Welcome. Today is {{</* now */>}}. Welcome. Today is {{</* now */>}}.
{{</* /greeting */>}} {{</* /greeting */>}}
{{< /code >}} {{< /code >}}
{{< code file="layouts/shortcodes/greeting.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/greeting.html" lang=go-html-template >}}
<div class="greeting"> <div class="greeting">
{{ trim .Inner "\r\n" | .Page.RenderString }} {{ trim .Inner "\r\n" | .Page.RenderString }}
</div> </div>
{{< /code >}} {{< /code >}}
{{< code file="layouts/shortcodes/now.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/now.html" lang=go-html-template >}}
{{- $dateFormat := "January 2, 2006 15:04:05" }} {{- $dateFormat := "January 2, 2006 15:04:05" }}
{{- with .Params }} {{- with .Params }}
+1 -1
View File
@@ -13,7 +13,7 @@ action:
The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter: The `Position` method is useful for error reporting. For example, if your shortcode requires a "greeting" parameter:
{{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template copy=false >}} {{< code file="layouts/shortcodes/myshortcode.html" lang=go-html-template >}}
{{ $greeting := "" }} {{ $greeting := "" }}
{{ with .Get "greeting" }} {{ with .Get "greeting" }}
{{ $greeting = . }} {{ $greeting = . }}