From e3624bb9862f6b84a0e1c19285e60c4cf57e9881 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 26 Sep 2020 16:31:26 +0300 Subject: [PATCH 1/4] Add a `gh` shortcode --- site/layouts/shortcodes/gh.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 site/layouts/shortcodes/gh.html diff --git a/site/layouts/shortcodes/gh.html b/site/layouts/shortcodes/gh.html new file mode 100644 index 000000000..09a719694 --- /dev/null +++ b/site/layouts/shortcodes/gh.html @@ -0,0 +1,25 @@ +{{- /* + Usage: gh "foo", where foo can be: + + * "pr 1" -> #1 + * "issue 2" -> #2 + * "@XhmikosR" -> @XhmikosR + * "a3b09530fb31cfe6bd14d49965c19e8f89c1b023" -> a3b0953 + * "a3b0953" -> a3b0953 + + Quotes are not always needed, but Hugo can choke on some characters like @, in which case wrap the parameter with quotes. Also, they are needed for PR and Issue +*/ -}} + +{{ range .Params -}} + {{- if hasPrefix . "@" -}} + {{ . }} + {{- else if hasPrefix (. | lower) "pr" -}} + #{{ trim (substr . 2) " " }} + {{- else if hasPrefix (. | lower) "issue" -}} + #{{ trim (substr . (len "issue")) " " }} + {{- else if or (eq (len .) 7) (eq (len .) 40) -}} + {{ trim (substr . 0 7) " " }} + {{- else -}} + {{ errorf `Wrong parameter passed in %q shortcode: %s` $.Name $.Position }} + {{- end -}} +{{- end -}} From d51374f9b9545c24b4dcfae33827fea7b0d4ba12 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 2 Oct 2020 16:56:43 +0300 Subject: [PATCH 2/4] WIP --- site/layouts/shortcodes/gh.html | 53 ++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/site/layouts/shortcodes/gh.html b/site/layouts/shortcodes/gh.html index 09a719694..5059998ef 100644 --- a/site/layouts/shortcodes/gh.html +++ b/site/layouts/shortcodes/gh.html @@ -1,25 +1,44 @@ {{- /* - Usage: gh "foo", where foo can be: + Usage: `gh type="foo" value="bar" text="foobar"`, where: - * "pr 1" -> #1 - * "issue 2" -> #2 - * "@XhmikosR" -> @XhmikosR - * "a3b09530fb31cfe6bd14d49965c19e8f89c1b023" -> a3b0953 - * "a3b0953" -> a3b0953 + * type: "issue", "pull", "pr", "pull request", "commit"/"hash", "user" - default: "issue" + * value or val: Required - `type`s value, i.e. 1 + * text: the link's text; default for PRs/Issues #number, @user for users - Quotes are not always needed, but Hugo can choke on some characters like @, in which case wrap the parameter with quotes. Also, they are needed for PR and Issue + Examples: + + * gh type=pr val=1 or gh val=1 -> #1 + * gh type=issue val=2-> #2 + * gh type=user value=XhmikosR -> @XhmikosR + * gh type=commit (or hash) value="a3b09530fb31cfe6bd14d49965c19e8f89c1b023" -> a3b0953 + * gh type=commit (or hash) value="a3b0953" -> a3b0953 + + Quotes are not always needed, but Hugo can choke on some characters like @, in which case wrap the parameter with quotes. */ -}} -{{ range .Params -}} - {{- if hasPrefix . "@" -}} - {{ . }} - {{- else if hasPrefix (. | lower) "pr" -}} - #{{ trim (substr . 2) " " }} - {{- else if hasPrefix (. | lower) "issue" -}} - #{{ trim (substr . (len "issue")) " " }} - {{- else if or (eq (len .) 7) (eq (len .) 40) -}} - {{ trim (substr . 0 7) " " }} +{{- $type := .Get "type" | default "pr" -}} +{{- $is_pr := or (eq $type "pull") (eq $type "pr") (eq $type "pull request") -}} +{{- $text := .Get "text" -}} +{{- $value := or (.Get "value") (.Get "val") -}} +{{- $commit := or (.Get "commit") (.Get "hash") -}} + +{{- if not $text -}} + {{- if eq $type "user" -}} + {{- $text = printf "@%s" $value -}} + {{- $type = "" -}} + {{- else if (or $is_pr (eq $type "issue")) -}} + {{- $text = printf "#%s" $value -}} + {{- if eq $type "issue" -}} + {{- $type = "issues" -}} + {{- else -}} + {{- $type = "pull" -}} + {{- end -}} + {{- else if (and (or $commit (eq (len $value) 7) (eq (len $value) 40))) -}} + {{- $text = printf "%s" (substr $value 0 7) -}} + {{- $type = "commit" -}} {{- else -}} - {{ errorf `Wrong parameter passed in %q shortcode: %s` $.Name $.Position }} + {{- errorf `Wrong parameter passed in %q shortcode: %s` $.Name $.Position -}} {{- end -}} {{- end -}} + +{{ $text }} \ No newline at end of file From 1e4d088c0008e037f861cc442a87b9a15d5be696 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 18 Nov 2020 17:36:55 +0200 Subject: [PATCH 3/4] Revert "WIP" --- site/layouts/shortcodes/gh.html | 53 +++++++++++---------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/site/layouts/shortcodes/gh.html b/site/layouts/shortcodes/gh.html index 5059998ef..09a719694 100644 --- a/site/layouts/shortcodes/gh.html +++ b/site/layouts/shortcodes/gh.html @@ -1,44 +1,25 @@ {{- /* - Usage: `gh type="foo" value="bar" text="foobar"`, where: + Usage: gh "foo", where foo can be: - * type: "issue", "pull", "pr", "pull request", "commit"/"hash", "user" - default: "issue" - * value or val: Required - `type`s value, i.e. 1 - * text: the link's text; default for PRs/Issues #number, @user for users + * "pr 1" -> #1 + * "issue 2" -> #2 + * "@XhmikosR" -> @XhmikosR + * "a3b09530fb31cfe6bd14d49965c19e8f89c1b023" -> a3b0953 + * "a3b0953" -> a3b0953 - Examples: - - * gh type=pr val=1 or gh val=1 -> #1 - * gh type=issue val=2-> #2 - * gh type=user value=XhmikosR -> @XhmikosR - * gh type=commit (or hash) value="a3b09530fb31cfe6bd14d49965c19e8f89c1b023" -> a3b0953 - * gh type=commit (or hash) value="a3b0953" -> a3b0953 - - Quotes are not always needed, but Hugo can choke on some characters like @, in which case wrap the parameter with quotes. + Quotes are not always needed, but Hugo can choke on some characters like @, in which case wrap the parameter with quotes. Also, they are needed for PR and Issue */ -}} -{{- $type := .Get "type" | default "pr" -}} -{{- $is_pr := or (eq $type "pull") (eq $type "pr") (eq $type "pull request") -}} -{{- $text := .Get "text" -}} -{{- $value := or (.Get "value") (.Get "val") -}} -{{- $commit := or (.Get "commit") (.Get "hash") -}} - -{{- if not $text -}} - {{- if eq $type "user" -}} - {{- $text = printf "@%s" $value -}} - {{- $type = "" -}} - {{- else if (or $is_pr (eq $type "issue")) -}} - {{- $text = printf "#%s" $value -}} - {{- if eq $type "issue" -}} - {{- $type = "issues" -}} - {{- else -}} - {{- $type = "pull" -}} - {{- end -}} - {{- else if (and (or $commit (eq (len $value) 7) (eq (len $value) 40))) -}} - {{- $text = printf "%s" (substr $value 0 7) -}} - {{- $type = "commit" -}} +{{ range .Params -}} + {{- if hasPrefix . "@" -}} + {{ . }} + {{- else if hasPrefix (. | lower) "pr" -}} + #{{ trim (substr . 2) " " }} + {{- else if hasPrefix (. | lower) "issue" -}} + #{{ trim (substr . (len "issue")) " " }} + {{- else if or (eq (len .) 7) (eq (len .) 40) -}} + {{ trim (substr . 0 7) " " }} {{- else -}} - {{- errorf `Wrong parameter passed in %q shortcode: %s` $.Name $.Position -}} + {{ errorf `Wrong parameter passed in %q shortcode: %s` $.Name $.Position }} {{- end -}} {{- end -}} - -{{ $text }} \ No newline at end of file From 5bcb6df688b1e07668e78e67005bb2e96c0a706c Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 13 Jan 2021 23:08:08 +0200 Subject: [PATCH 4/4] Use the `gh` shortcode --- site/content/docs/5.0/components/popovers.md | 2 +- site/content/docs/5.0/components/tooltips.md | 2 +- site/content/docs/5.0/getting-started/rtl.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/site/content/docs/5.0/components/popovers.md b/site/content/docs/5.0/components/popovers.md index ccaf1f63f..fed71f21d 100644 --- a/site/content/docs/5.0/components/popovers.md +++ b/site/content/docs/5.0/components/popovers.md @@ -198,7 +198,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt selector string | false false - If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example. + If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See {{< gh "issue 4215" >}} and an informative example. template diff --git a/site/content/docs/5.0/components/tooltips.md b/site/content/docs/5.0/components/tooltips.md index 8f5aac533..ff7f0094d 100644 --- a/site/content/docs/5.0/components/tooltips.md +++ b/site/content/docs/5.0/components/tooltips.md @@ -220,7 +220,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt selector string | false false - If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See this and an informative example. + If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (jQuery.on support). See {{< gh "issue 4215" >}} and an informative example. template diff --git a/site/content/docs/5.0/getting-started/rtl.md b/site/content/docs/5.0/getting-started/rtl.md index 4ade8359c..866bbbbb3 100644 --- a/site/content/docs/5.0/getting-started/rtl.md +++ b/site/content/docs/5.0/getting-started/rtl.md @@ -169,7 +169,7 @@ While this approach is understandable, please pay attention to the following: 1. When switching `.ltr` and `.rtl`, make sure you add `dir` and `lang` attributes accordingly. 2. Loading both files can be a real performance bottleneck: consider some [optimization]({{< docsref "/customize/optimize" >}}), and maybe try to [load one of those files asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/). -3. Nesting styles this way will prevent our `form-validation-state()` mixin from working as intended, thus require you tweak it a bit by yourself. [See #31223](https://github.com/twbs/bootstrap/issues/31223). +3. Nesting styles this way will prevent our `form-validation-state()` mixin from working as intended, thus require you tweak it a bit by yourself. See {{< gh "issue 31223" >}}. {{< /callout >}} ## The breadcrumb case