From dbec2962f400da4f01d12f39d57981364525b5a4 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Thu, 4 May 2023 10:25:54 -0400 Subject: [PATCH 1/4] Drop mycplus.com iframe from Shortcode page (#1475) --- .../en/docs/adding-content/shortcodes/index.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/userguide/content/en/docs/adding-content/shortcodes/index.md b/userguide/content/en/docs/adding-content/shortcodes/index.md index c3a2cb16a..ef7de03c9 100644 --- a/userguide/content/en/docs/adding-content/shortcodes/index.md +++ b/userguide/content/en/docs/adding-content/shortcodes/index.md @@ -120,11 +120,9 @@ For announcement of latest features etc. ### blocks/feature ```go-html-template - {{%/* blocks/feature icon="fa-brands fa-github" title="Contributions welcome!" url="https://github.com/gohugoio/hugo" */%}} We do a [Pull Request](https://github.com/gohugoio/hugo/pulls) contributions workflow on **GitHub**. New users are always welcome! {{%/* /blocks/feature */%}} - ``` | Parameter | Default | Description | @@ -139,7 +137,6 @@ We do a [Pull Request](https://github.com/gohugoio/hugo/pulls) contributions wor The **blocks/link-down** shortcode creates a navigation link down to the next section. It's meant to be used in combination with the other blocks shortcodes. ```go-html-template -
{{}}
@@ -179,7 +176,6 @@ The **pageinfo** shortcode creates a text box that you can use to add banner inf {{%/* pageinfo color="primary" */%}} This is placeholder content. {{%/* /pageinfo */%}} - ``` Renders to: @@ -197,7 +193,6 @@ This is placeholder content The **imgproc** shortcode finds an image in the current [Page Bundle](/docs/adding-content/content/#page-bundles) and scales it given a set of processing instructions. - ```go-html-template {{}} Norway Spruce Picea abies shoot with foliage buds. @@ -388,9 +383,6 @@ object HelloWorld extends App { println("Hello world!") } {{< /tab >}} -{{< tab header="Reference" right=true text=true >}} -{{< iframe src="https://www.mycplus.com/featured-articles/hello-world-programs-in-300-programming-languages" >}} -{{< /tab >}} {{< /tabpane >}} The Docsy template provides two shortcodes `tabpane` and `tab` that let you easily create tabbed panes. To see how to use them, have a look at the following code block, which renders to a right aligned pane with one disabled and three active tabs: @@ -606,7 +598,6 @@ Check system compatibility before proceeding. `sudo sh install.sh` 1. Test that your installation was successfully completed. - ``` You can import this section into another document: @@ -615,7 +606,6 @@ You can import this section into another document: The following section explains how to install the database: {{%/* readfile "installation.md" */%}} - ``` This is rendered as if the instructions were in the parent document. Hugo @@ -650,7 +640,6 @@ To create a new pipeline, follow the next steps: {{}} 1. Apply the file to your cluster `kubectl apply config.yaml` - ``` This code automatically reads the content of `includes/config.yaml` and inserts it @@ -660,11 +649,11 @@ into the document. The rendered text looks like this: To create a new pipeline, follow the next steps: -1. Create a configuration file `config.yaml`: +1. Create a configuration file `config.yaml`: {{< readfile file="includes/config.yaml" code="true" lang="yaml" >}} -1. Apply the file to your cluster `kubectl apply config.yaml` +1. Apply the file to your cluster `kubectl apply config.yaml` --- From e977fe3015ba9bc53ef61cb2efc510e77a5e41bf Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Thu, 4 May 2023 16:48:37 +0200 Subject: [PATCH 2/4] [BSv5] Adapt cardpane shortcode --- CHANGELOG.md | 8 ++ assets/scss/shortcodes/cards-pane.scss | 3 +- layouts/shortcodes/card-code.html | 28 +++---- layouts/shortcodes/card.html | 76 +++++++++---------- layouts/shortcodes/cardpane.html | 4 +- .../docs/adding-content/shortcodes/index.md | 69 +++++++++-------- 6 files changed, 95 insertions(+), 93 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index babb0b1d2..ba0afe781 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,14 @@ For a list of issues targeted for the next release, see the [23Q1][] milestone. - `blocks/section`: **default** and accepted values of the `type` argument have changed! For details see [blocks/section] ([#1472]). +- **[Adaptation of shortcodes for diplay of cards (#1376)][1376]: + - shortcode `cardpane`: renamed CSS class `td-card-deck` to `td-card-group`. + - shortcode `card`, `card-code`: markup of inner content (html/markdown) + now depends on the syntax of the calling shortcode, not on extension + of page file any more [#906][906]. + - shortcode `card-code` is now deprecated, use shortcode `card` with named + parameter `code=true` instead. + **Other changes**: - Non-breaking changes that result from the Bootstrap v5 upgrade: diff --git a/assets/scss/shortcodes/cards-pane.scss b/assets/scss/shortcodes/cards-pane.scss index bea122b8a..f3af98751 100644 --- a/assets/scss/shortcodes/cards-pane.scss +++ b/assets/scss/shortcodes/cards-pane.scss @@ -1,4 +1,4 @@ -.td-card-deck.card-deck { +.td-card-group.card-group { @extend .td-max-width-on-larger-screens; } @@ -8,6 +8,7 @@ .highlight { border: none; + margin: 0; } } diff --git a/layouts/shortcodes/card-code.html b/layouts/shortcodes/card-code.html index a7c5465d8..28908907f 100644 --- a/layouts/shortcodes/card-code.html +++ b/layouts/shortcodes/card-code.html @@ -1,20 +1,16 @@ -
- {{ $lang := "" }} - {{ with $.Get "lang" }} - {{ $lang = $.Get "lang" }} - {{ end }} - {{ $highlight := "" }} - {{ with $.Get "highlight" }} - {{ $highlight = $.Get "highlight" }} - {{ end }} - {{- with $.Get "header" -}} +{{ warnf `shortcode 'card-code' is deprecated: use shortcode 'card' with named parameter 'code=true' instead.` -}} +{{ $lang := default "" ($.Get "lang") -}} +{{ $highlight := default "" ($.Get "highlight") -}} + +
+ {{ with $.Get "header" -}}
- {{- $.Get "header" | markdownify -}} + {{ . | markdownify -}}
- {{end}} -
- {{ with $.Inner }} - {{- highlight $.Inner $lang $highlight -}} - {{ end }} + {{ end -}} +
+ {{ with $.Inner -}} + {{ highlight . $lang $highlight -}} + {{ end -}}
diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index f0558133b..74138a1f3 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -1,49 +1,47 @@ -
- {{ with $.Get "header" }} -
- {{ if eq $.Page.File.Ext "md" }} - {{ $.Get "header" | markdownify }} - {{ else }} - {{ $.Get "header" | htmlUnescape | safeHTML }} - {{ end }} +{{/* Check parameter type */ -}} +{{ $code := false -}} +{{ with .Get "code" -}} + {{ $type := printf "%T" . -}} + {{ if ne $type "bool" -}} + {{ errorf `shortcode 'card': boolean value expected for parameter 'code', but got %s` $type -}} + {{ else }} + {{ $code = . -}} + {{ end -}} +{{ end -}} + +{{ $lang := default "" (.Get "lang") -}} +{{ $highlight := default "" (.Get "highlight") -}} + +
+{{ with $.Get "header" -}} +
+ {{ . | markdownify }}
- {{ end }} -
- {{ with $.Get "title" }} +{{ end -}} +
+ {{ with $.Get "title" -}}
- {{ if eq $.Page.File.Ext "md" }} - {{ $.Get "title" | markdownify }} - {{ else }} - {{ $.Get "title" | htmlUnescape | safeHTML }} - {{ end }} + {{ . | markdownify -}}
- {{ end }} - {{ with $.Get "subtitle" }} -
- {{ if eq $.Page.File.Ext "md" }} - {{ $.Get "subtitle" | markdownify }} - {{ else }} - {{ $.Get "subtitle" | htmlUnescape | safeHTML }} - {{ end }} + {{ end -}} + {{ with $.Get "subtitle" -}} +
+ {{ . | markdownify -}}
- {{ end }} - {{ with $.Inner }} + {{ end -}} + {{ with $.Inner -}} + {{ if $code -}} + {{ highlight . $lang $highlight -}} + {{ else -}}

- {{ if eq $.Page.File.Ext "md" }} - {{ $.Inner | markdownify }} - {{ else }} - {{ $.Inner | htmlUnescape | safeHTML }} - {{ end }} + {{ . -}}

- {{ end }} + {{ end -}} + {{ end -}}
- {{ with $.Get "footer" }} + {{ with $.Get "footer" -}} - {{ end }} + {{ end -}}
diff --git a/layouts/shortcodes/cardpane.html b/layouts/shortcodes/cardpane.html index 2617fdbaa..caa3f8b66 100644 --- a/layouts/shortcodes/cardpane.html +++ b/layouts/shortcodes/cardpane.html @@ -1,3 +1,3 @@ -
+
{{- .Inner -}} -
\ No newline at end of file +
diff --git a/userguide/content/en/docs/adding-content/shortcodes/index.md b/userguide/content/en/docs/adding-content/shortcodes/index.md index ef7de03c9..f2806ac3b 100644 --- a/userguide/content/en/docs/adding-content/shortcodes/index.md +++ b/userguide/content/en/docs/adding-content/shortcodes/index.md @@ -417,7 +417,7 @@ This code translates to the right aligned tabbed pane below, showing a `Welcome! Herzlich willkommen! Flag Germany {{< /tab >}} - {{% tab header="Swahili" lang="sw" %}} + {{% tab header="Swahili" lang="sw" %}} ![Flag Tanzania](flags/tz.png) **Karibu sana!** {{% /tab %}} @@ -428,9 +428,9 @@ This code translates to the right aligned tabbed pane below, showing a `Welcome! Tabbed panes are implemented using two shortcodes: * The `tabpane` shortcode, which is the container element for the tabs. This shortcode can hold the optional named parameters `lang`, `highlight` and `right`. The value of the optional parameters `lang` and `highlight` are passed on as second `LANG` and third `OPTIONS` arguments to Hugo's built-in [`highlight`](https://gohugo.io/functions/highlight/) function which is used to render the code blocks of the individual tabs. Specify `right=true` if you want to right align your tabs. In case the header text of the tab equals the language used in the tab's code block (as in the first tabbed pane example above), you may specify `langEqualsHeader=true` in the surrounding `tabpane` shortcode. Then, the header text of the individual tab is automatically set as `lang` parameter of the respective tab. -* The various `tab` shortcodes represent the tabs you would like to show. Specify the named parameter `header` for each tab in order to set the header text of the tab. If the `header` parameter is the only parameter inside your tab shortcode, you can specify the header as unnamed parameter, something like `{ tab "My header" }} … {{ /tab }}`. If your `tab` shortcode does not have any parameters, the header of the tab will default to `Tab n`. To split the panes into a left aligned and a right aligned tab group, specify `right=true` in the dividing tab. By giving `right=true` several times, you can even render multiple tab groups. You can disable a tab by specifying the parameter `disabled=true`. For enabled tabs, there are two modes for content display, `code` representation and _textual_ representation: +* The various `tab` shortcodes represent the tabs you would like to show. Specify the named parameter `header` for each tab in order to set the header text of the tab. If the `header` parameter is the only parameter inside your tab shortcode, you can specify the header as unnamed parameter, something like `{{< tab "My header" >}} … {{< /tab >}}`. If your `tab` shortcode does not have any parameters, the header of the tab will default to `Tab n`. To split the panes into a left aligned and a right aligned tab group, specify `right=true` in the dividing tab. By giving `right=true` several times, you can even render multiple tab groups. You can disable a tab by specifying the parameter `disabled=true`. For enabled tabs, there are two modes for content display, `code` representation and _textual_ representation: * By default, the tab's content is rendered as `code block`. In order to get proper syntax highlighting, specify the named parameter `lang` --and optionally the parameter `highlight`-- for each tab. Parameters set in the parent `tabpane` shortcode will be overwritten. - * If the contents of your tabs should be rendered as text with different styles and with optional images, specify `text=true` as parameter of your `tabpane` (or your `tab`). If your content is markdown, use the percent sign `%` as outermost delimiter of your `tab` shortcode, your markup should look like `{{%/* tab */%}}`Your \*\*markdown\*\* content`{{%/* /tab */%}}`. In case of HTML content, use square brackets `<>` as outermost delimiters: `{{}}`Your <b>HTML</b> content`{{}}`. + * If the contents of your tabs should be rendered as text with different styles and with optional images, specify `text=true` as parameter of your `tabpane` (or your `tab`). If your content is markdown, use the percent sign `%` as outermost delimiter of your `tab` shortcode, your markup should look like `{{%/* tab */%}}Your **markdown** content{{%/* /tab */%}}`. In case of HTML content, use square brackets `<>` as outermost delimiters: `{{}}Your HTML content{{}}`. {{% alert title="Info" %}} By default, the language of the selected tab is stored and preserved between different browser sessions. If the content length within your tabs differs greatly, this may lead to unwanted scrolling when switching between tabs. To disable this unwanted behaviour, specify `persistLang=false` within your `tabpane` shortcode. @@ -440,30 +440,29 @@ By default, the language of the selected tab is stored and preserved between dif When authoring content, it's sometimes very useful to put similar text blocks or code fragments on card like elements, which can be optionally presented side by side. Let's showcase this feature with the following sample card group which shows the first four Presidents of the United States: -{{< cardpane >}} -{{< card header="**George Washington**" title="\*1732     †1799" subtitle="**President:** 1789 – 1797" footer="![SignatureGeorgeWashington](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/George_Washington_signature.svg/320px-George_Washington_signature.svg.png 'Signature George Washington')">}} +{{% cardpane %}} +{{% card header="**George Washington**" title="\*1732     †1799" subtitle="**President:** 1789 – 1797" footer="![SignatureGeorgeWashington](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/George_Washington_signature.svg/320px-George_Washington_signature.svg.png 'Signature George Washington')" %}} ![PortraitGeorgeWashington](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/633px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg "Portrait George Washington") -{{< /card >}} -{{< card header="**John Adams**" title="\* 1735     † 1826" subtitle="**President:** 1797 – 1801" footer="![SignatureJohnAdams](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/John_Adams_Sig_2.svg/320px-John_Adams_Sig_2.svg.png 'Signature John Adams')" >}} +{{% /card %}} +{{% card header="**John Adams**" title="\* 1735     † 1826" subtitle="**President:** 1797 – 1801" footer="![SignatureJohnAdams](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/John_Adams_Sig_2.svg/320px-John_Adams_Sig_2.svg.png 'Signature John Adams')" %}} ![PortraitJohnAdams](https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Gilbert_Stuart%2C_John_Adams%2C_c._1800-1815%2C_NGA_42933.jpg/633px-Gilbert_Stuart%2C_John_Adams%2C_c._1800-1815%2C_NGA_42933.jpg "Portrait John Adams") -{{< /card >}} -{{< card header="**Thomas Jefferson**" title="\* 1743     † 1826" subtitle="**President:** 1801 – 1809" footer="![SignatureThomasJefferson](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Thomas_Jefferson_Signature.svg/320px-Thomas_Jefferson_Signature.svg.png 'Signature Thomas Jefferson')" >}} +{{% /card %}} +{{% card header="**Thomas Jefferson**" title="\* 1743     † 1826" subtitle="**President:** 1801 – 1809" footer="![SignatureThomasJefferson](https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Thomas_Jefferson_Signature.svg/320px-Thomas_Jefferson_Signature.svg.png 'Signature Thomas Jefferson')" %}} ![PortraitThomasJefferson](https://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Official_Presidential_portrait_of_Thomas_Jefferson_%28by_Rembrandt_Peale%2C_1800%29%28cropped%29.jpg/390px-Official_Presidential_portrait_of_Thomas_Jefferson_%28by_Rembrandt_Peale%2C_1800%29%28cropped%29.jpg "Portrait Thomas Jefferson") -{{< /card >}} -{{< card header="**James Madison**" title="\* 1751     † 1836" subtitle="**President:** 1809 – 1817" footer="![SignatureJamesMadison](https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/James_Madison_sig.svg/320px-James_Madison_sig.svg.png 'Signature James Madison')" >}} +{{% /card %}} +{{% card header="**James Madison**" title="\* 1751     † 1836" subtitle="**President:** 1809 – 1817" footer="![SignatureJamesMadison](https://upload.wikimedia.org/wikipedia/commons/thumb/3/39/James_Madison_sig.svg/320px-James_Madison_sig.svg.png 'Signature James Madison')" %}} ![PortraitJamesMadison](https://upload.wikimedia.org/wikipedia/commons/thumb/2/20/James_Madison%28cropped%29%28c%29.jpg/393px-James_Madison%28cropped%29%28c%29.jpg "Portrait James Madison") -{{< /card >}} -{{< /cardpane >}} +{{% /card %}} +{{% /cardpane %}} Docsy supports creating such card panes via different shortcodes: * The `cardpane` shortcode which is the container element for the various cards to be presented. -* The `card` shortcodes, with each shortcode representing an individual card. While cards are often presented inside a card group, a single card may stand on its own, too. A `card` shortcode can hold text, images or any other arbitrary kind of markdown or HTML markup as content. If your content is programming code, you are advised to make use of the `card-code` shortcode, a special kind of card with code-highlighting and other optional features like line numbers, highlighting of certain lines, …. +* The `card` shortcodes, with each shortcode representing an individual card. While cards are often presented inside a card group, a single card may stand on its own, too. A `card` shortcode can hold programming code, text, images or any other arbitrary kind of markdown or HTML markup as content. In case of programming code, cards provide automatic code-highlighting and other optional features like line numbers, highlighting of certain lines, …. -### Shortcode `card` (for text, images, …) +### Shortcode `card`: textual content -As stated above, a card is coded using one of the shortcode `card` or `card-code`. -If your content is any kind of text other than programming code, use the universal `card`shortcode. The following code sample demonstrates how to code a card element: +Make use of the `card` shortcode to display a card. The following code sample demonstrates how to code a card element: ```go-html-template {{}} -{{< card header="**Imagine**" title="Artist and songwriter: John Lennon" subtitle="Co-writer: Yoko Ono" footer="![SignatureJohnLennon](https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Firma_de_John_Lennon.svg/320px-Firma_de_John_Lennon.svg.png 'Signature John Lennon')">}} +{{% cardpane %}} +{{< card header="**Imagine**" title="Artist and songwriter: John Lennon" subtitle="Co-writer: Yoko Ono" footer="![SignatureJohnLennon](https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Firma_de_John_Lennon.svg/320px-Firma_de_John_Lennon.svg.png 'Signature John Lennon')" >}} Imagine there's no heaven, It's easy if you try
No hell below us, above us only sky
Imagine all the people living for today… @@ -494,19 +493,19 @@ Imagine all the people sharing all the world… You may say I'm a dreamer, but I'm not the only one
I hope someday you'll join us and the world will live as one {{< /card >}} -{{< card header="**Header**: specified via named parameter `Header`" title="**Card title**: specified via named parameter `title`" subtitle="**Card subtitle**: specified via named parameter `subtitle`" footer="**Footer**: specified via named parameter `footer`" >}} - **Content**: inner content of the shortcode, this may be formatted text, images, videos, … . If the extension of your page file equals `.md`, markdown format is expected, otherwise, your content will be treated as plain HTML. -{{< /card >}} -{{< /cardpane >}} +{{% card header="**Header**: specified via named parameter `Header`" title="**Card title**: specified via named parameter `title`" subtitle="**Card subtitle**: specified via named parameter `subtitle`" footer="**Footer**: specified via named parameter `footer`" %}} + **Content**: inner content of the shortcode, this may be plain text or formatted text, images, videos, … . If your content is markdown, use the percent sign `%` as outermost delimiter of your `card` shortcode, your markup should look like `{{%/* card */%}}Your **markdown** content{{%/* /card */%}}`. In case of HTML content, use square brackets `<>` as outermost delimiters: `{{}}Your HTML content{{}}` +{{% /card %}} +{{% /cardpane %}} While the main content of the card is taken from the inner markup of the `card` shortcode, the optional elements `footer`, `header`, `title`, and `subtitle` are all specified as named parameters of the shortcode. -### Shortcode `card-code` (for programming code) +### Shortcode `card`: programming code -In case you want to display programming code on your card, a special shortcode `card-code` is provided for this purpose. The following sample demonstrates how to code a card element with the famous `Hello world!`application coded in C: +If you want to display programming code on your card, set the named parameter `code` of the card to `true`. The following sample demonstrates how to code a card element with the famous `Hello world!` application coded in C: ```go-html-template -{{}} +{{}} #include #include @@ -515,12 +514,12 @@ int main(void) puts("Hello World!"); return EXIT_SUCCESS; } -{{}} +{{}} ``` This code translates to the card shown below: -{{< card-code header="**C**" lang="C" highlight="" >}} +{{< card code=true header="**C**" lang="C" highlight="" >}} #include #include @@ -529,9 +528,9 @@ int main(void) puts("Hello World!"); return EXIT_SUCCESS; } -{{< /card-code >}} +{{< /card >}} -
The `card-code` shortcode can optionally hold the named parameters `lang` and/or `highlight`. The values of these optional parameters are passed on as second `LANG` and third `OPTIONS` arguments to Hugo's built-in [`highlight`](https://gohugo.io/functions/highlight/) function which is used to render the code block presented on the card. +
If called with parameter `code=true`, the `card` shortcode can optionally hold the named parameters `lang` and/or `highlight`. The values of these optional parameters are passed on as second `LANG` and third `OPTIONS` arguments to Hugo's built-in [`highlight`](https://gohugo.io/functions/highlight/) function which is used to render the code block presented on the card. ### Card groups @@ -555,18 +554,18 @@ The general markup of a card group resembles closely the markup of a tabbed pane Contrary to tabs, cards are presented side by side, however. This is especially useful it you want to compare different programming techniques (traditional vs. modern) on two cards, like demonstrated in the example above: {{< cardpane >}} -{{< card-code header="**Java 5**" >}} +{{< card code=true header="**Java 5**" >}} File[] hiddenFiles = new File("directory_name") .listFiles(new FileFilter() { public boolean accept(File file) { return file.isHidden(); } }); -{{< /card-code >}} -{{< card-code header="**Java 8, Lambda expression**" >}} +{{< /card >}} +{{< card code=true header="**Java 8, Lambda expression**" >}} File[] hiddenFiles = new File("directory_name") .listFiles(File::isHidden); -{{< /card-code >}} +{{< /card >}} {{< /cardpane >}} ## Include external files @@ -662,7 +661,7 @@ You must use `{{}}` delimiters for the code highlighting to work correctly. {{% /alert %}} -The "file" parameter is the relative path to the file. Only relative paths +The `file` parameter is the relative path to the file. Only relative paths under the parent file's working directory are supported. For files outside the current working directory you can use an absolute path From 15bb85789703132d3d347d6f78bc5c062b792300 Mon Sep 17 00:00:00 2001 From: Andreas Deininger Date: Thu, 4 May 2023 20:08:02 +0200 Subject: [PATCH 3/4] Tabpane shortcodes: improved reporting of warnings and errors (#1478) --- layouts/shortcodes/blocks/lead.html | 2 +- layouts/shortcodes/imgproc.html | 28 +++++++++---------- layouts/shortcodes/tab.html | 13 +++++---- layouts/shortcodes/tabpane.html | 12 ++++---- .../docs/adding-content/shortcodes/index.md | 2 +- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/layouts/shortcodes/blocks/lead.html b/layouts/shortcodes/blocks/lead.html index 6c12d6203..5afe34c64 100644 --- a/layouts/shortcodes/blocks/lead.html +++ b/layouts/shortcodes/blocks/lead.html @@ -2,7 +2,7 @@ {{ $height := .Get "height" | default "auto" -}} {{ with .Get "height" -}} {{ if not ( or ( eq . "auto" ) ( eq . "min" ) ( eq . "med" ) ( eq . "max" ) ( eq . "full" ) ) -}} - {{ errorf "shortcode 'lead': parameter height is '%s', must be one of 'auto', 'min', 'med', 'max' or 'full'." . -}} + {{ errorf "shortcode 'lead': parameter height is %q, must be one of 'auto', 'min', 'med', 'max' or 'full'." . -}} {{ end -}} {{ end -}} diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html index 6c5a211f9..318f0f240 100644 --- a/layouts/shortcodes/imgproc.html +++ b/layouts/shortcodes/imgproc.html @@ -1,17 +1,17 @@ -{{ $original := .Page.Resources.GetMatch (printf "**%s*" (.Get 0)) }} -{{ $command := .Get 1 }} -{{ $options := .Get 2 }} -{{ if eq $command "Fit"}} -{{ .Scratch.Set "image" ($original.Fit $options) }} -{{ else if eq $command "Resize"}} -{{ .Scratch.Set "image" ($original.Resize $options) }} -{{ else if eq $command "Fill"}} -{{ .Scratch.Set "image" ($original.Fill $options) }} -{{ else if eq $command "Crop"}} -{{ .Scratch.Set "image" ($original.Crop $options) }} -{{ else }} -{{ errorf "Invalid image processing command: Must be one of Fit, Fill, Crop or Resize."}} -{{ end }} +{{ $original := .Page.Resources.GetMatch (printf "**%s*" (.Get 0)) -}} +{{ $command := .Get 1 -}} +{{ $options := .Get 2 -}} +{{ if eq $command "Fit" -}} +{{ .Scratch.Set "image" ($original.Fit $options) -}} +{{ else if eq $command "Resize" -}} +{{ .Scratch.Set "image" ($original.Resize $options) -}} +{{ else if eq $command "Fill" -}} +{{ .Scratch.Set "image" ($original.Fill $options) -}} +{{ else if eq $command "Crop" -}} +{{ .Scratch.Set "image" ($original.Crop $options) -}} +{{ else -}} +{{ errorf "Invalid image processing command %q: must be one of Fit, Fill, Crop or Resize." $command -}} +{{ end -}} {{ $image := .Scratch.Get "image" }}
diff --git a/layouts/shortcodes/tab.html b/layouts/shortcodes/tab.html index 8ec7e09d5..d13e0338e 100644 --- a/layouts/shortcodes/tab.html +++ b/layouts/shortcodes/tab.html @@ -1,8 +1,11 @@ {{- /* Make sure that we are enclosed within a tabpane shortcode block */ -}} + {{ with $.Parent -}} -{{ if ne $.Parent.Name "tabpane" -}} - {{ errorf "shortcode 'tab' must be used within a 'tabpane' block" -}} + {{ if ne $.Parent.Name "tabpane" -}} + {{ errorf "Found shortcode %q enclosed inside a %q block, must be enclosed inside a %q block. Error position: %s" $.Name $.Parent.Name "tabpane" $.Position -}} {{ end -}} +{{ else -}} + {{ errorf "shortcode %q must be enclosed inside a %q block, but no parent block was found. Error position: %s" $.Name "tabpane" $.Position -}} {{ end -}} {{ $header := "Tab" -}} @@ -23,19 +26,19 @@ {{ end -}} {{ with $.Get "text" -}} {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tab: parameter 'text' must be either true or false" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "text" (printf "%T" .) $.Position -}} {{ end -}} {{ $tab = merge $tab (dict "text" ($.Get "text")) -}} {{ end -}} {{ with $.Get "right" -}} {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tab: parameter 'right' must be either true or false" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "right" (printf "%T" .) $.Position -}} {{ end -}} {{ $tab = merge $tab (dict "rightpush" ($.Get "right")) -}} {{ end -}} {{ with $.Get "disabled" -}} {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tab: parameter 'disabled' must be either true or false" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "disabled" (printf "%T" .) $.Position -}} {{ end -}} {{ $tab = merge $tab (dict "disabled" ($.Get "disabled")) -}} {{ end -}} diff --git a/layouts/shortcodes/tabpane.html b/layouts/shortcodes/tabpane.html index d22a59a19..c553383db 100644 --- a/layouts/shortcodes/tabpane.html +++ b/layouts/shortcodes/tabpane.html @@ -1,25 +1,25 @@ {{/* Check parameter types */ -}} {{ with .Get "langEqualsHeader" -}} - {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tabpane: parameter 'langEqualsHeader' must be either true or false" -}} + {{ if ne ( printf "%T" . ) "bool" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "langEqualsHeader" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} {{ with .Get "text" -}} {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tabpane: parameter 'text' must be either true or false" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "text" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} {{ with .Get "persistLang" -}} {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tabpane: parameter 'persistLang' must be either true or false" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "persistLang" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} {{ with .Get "right" -}} {{ if ne ( printf "%T" . ) "bool" -}} - {{ errorf "shortcode tabpane: parameter 'right' must be either true or false" -}} + {{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "right" (printf "%T" .) $.Position -}} {{ end -}} {{ end -}} @@ -101,7 +101,7 @@ {{ if $duplicate -}} - {{ warnf "Tabpane on page '%s': duplicate language '%s' detected, disabling persistance of language to avoid multiple tab display." .Page.RelPermalink $duplicateLang -}} + {{ warnf "Shortcode %q: duplicate language %q detected, disabling persistance of language to avoid multiple tab display. Position: %s" $.Name $duplicateLang $.Position -}} {{ end -}} {{ $duplicate = false -}} {{ $langs = slice -}} diff --git a/userguide/content/en/docs/adding-content/shortcodes/index.md b/userguide/content/en/docs/adding-content/shortcodes/index.md index f2806ac3b..e8e9f3509 100644 --- a/userguide/content/en/docs/adding-content/shortcodes/index.md +++ b/userguide/content/en/docs/adding-content/shortcodes/index.md @@ -428,7 +428,7 @@ This code translates to the right aligned tabbed pane below, showing a `Welcome! Tabbed panes are implemented using two shortcodes: * The `tabpane` shortcode, which is the container element for the tabs. This shortcode can hold the optional named parameters `lang`, `highlight` and `right`. The value of the optional parameters `lang` and `highlight` are passed on as second `LANG` and third `OPTIONS` arguments to Hugo's built-in [`highlight`](https://gohugo.io/functions/highlight/) function which is used to render the code blocks of the individual tabs. Specify `right=true` if you want to right align your tabs. In case the header text of the tab equals the language used in the tab's code block (as in the first tabbed pane example above), you may specify `langEqualsHeader=true` in the surrounding `tabpane` shortcode. Then, the header text of the individual tab is automatically set as `lang` parameter of the respective tab. -* The various `tab` shortcodes represent the tabs you would like to show. Specify the named parameter `header` for each tab in order to set the header text of the tab. If the `header` parameter is the only parameter inside your tab shortcode, you can specify the header as unnamed parameter, something like `{{< tab "My header" >}} … {{< /tab >}}`. If your `tab` shortcode does not have any parameters, the header of the tab will default to `Tab n`. To split the panes into a left aligned and a right aligned tab group, specify `right=true` in the dividing tab. By giving `right=true` several times, you can even render multiple tab groups. You can disable a tab by specifying the parameter `disabled=true`. For enabled tabs, there are two modes for content display, `code` representation and _textual_ representation: +* The various `tab` shortcodes represent the tabs you would like to show. Specify the named parameter `header` for each tab in order to set the header text of the tab. If the `header` parameter is the only parameter inside your tab shortcode, you can specify the header as unnamed parameter, something like `{{}} … {{}}`. If your `tab` shortcode does not have any parameters, the header of the tab will default to `Tab n`. To split the panes into a left aligned and a right aligned tab group, specify `right=true` in the dividing tab. By giving `right=true` several times, you can even render multiple tab groups. You can disable a tab by specifying the parameter `disabled=true`. For enabled tabs, there are two modes for content display, `code` representation and _textual_ representation: * By default, the tab's content is rendered as `code block`. In order to get proper syntax highlighting, specify the named parameter `lang` --and optionally the parameter `highlight`-- for each tab. Parameters set in the parent `tabpane` shortcode will be overwritten. * If the contents of your tabs should be rendered as text with different styles and with optional images, specify `text=true` as parameter of your `tabpane` (or your `tab`). If your content is markdown, use the percent sign `%` as outermost delimiter of your `tab` shortcode, your markup should look like `{{%/* tab */%}}Your **markdown** content{{%/* /tab */%}}`. In case of HTML content, use square brackets `<>` as outermost delimiters: `{{}}Your HTML content{{}}`. From 13db293f5217aa92b15aa7514bee34a43f241039 Mon Sep 17 00:00:00 2001 From: Razon Yang Date: Sun, 7 May 2023 02:17:21 +0800 Subject: [PATCH 4/4] module: ignore Bootstrap config (#1509) --- dependencies/config.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/dependencies/config.toml b/dependencies/config.toml index 3ba31f38f..a70111057 100644 --- a/dependencies/config.toml +++ b/dependencies/config.toml @@ -25,6 +25,7 @@ _merge = "deep" [[module.imports]] path = "github.com/twbs/bootstrap" disable = false + ignoreConfig = true [[module.imports.mounts]] source = "scss" target = "assets/vendor/bootstrap/scss"