Merge pull request #681 from gethinode/validation

Refactor sub, sup, spinner, release, persona, navbar, nav, mark, and link
This commit is contained in:
Mark Dumay
2023-12-27 10:01:17 +01:00
committed by GitHub
34 changed files with 889 additions and 584 deletions

BIN
assets/img/creator-1x1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 MiB

View File

@@ -4,20 +4,16 @@ arguments:
header:
type: string
optional: false
comment: >-
Header of the accordion item.
comment: Header of the accordion item.
show:
type: bool
optional: true
comment: >-
flag to indicate an item should be shown as collapsed.
comment: Flag to indicate an item should be shown as collapsed.
class:
type: string
optional: true
comment: >-
Class attribute of the accordion item.
comment: Class attribute of the accordion item.
body:
optional: false
comment: >-
Content of the accordion item.
comment: Content of the accordion item.
group: shortcode

View File

@@ -15,5 +15,4 @@ arguments:
class:
type: string
optional: true
comment: >-
Class attribute of the accordion, e.g. “w-50”.
comment: Class attribute of the accordion, e.g. “w-50”.

View File

@@ -2,51 +2,45 @@ comment: >-
Use the alert shortcode to display a contextual feedback message. The inner
content is used as alert text.
arguments:
class:
type: string
optional: true
comment: >-
Class attribute of the alert element.
color:
type: select
optional: true
default: danger
comment: >-
Theme color of the alert.
options:
values:
- primary
- secondary
- success
- danger
- warning
- info
- light
- dark
- white
- black
dismissible:
type: bool
optional: true
default: false
comment: >-
Flag to indicate the alert is dismissible.
icon:
type: string
optional: true
comment: >-
Font Awesome icon to include.
type:
type: select
optional: true
comment: >-
Type of the alert, generates an alert with related color and icon.
options:
values:
- danger
- info
class:
type: string
optional: true
comment: Class attribute of the alert element.
color:
type: select
optional: true
default: danger
comment: Theme color of the alert.
options:
values:
- primary
- secondary
- success
- danger
- warning
- info
- light
- dark
- white
- black
dismissible:
type: bool
optional: true
default: false
comment: Flag to indicate the alert is dismissible.
icon:
type: string
optional: true
comment: Font Awesome icon to include.
type:
type: select
optional: true
comment: Type of the alert, generates an alert with related color and icon.
options:
values:
- danger
- info
body:
optional: false
comment: >-
Alert text.
comment: Alert text.
group: shortcode

74
data/structures/link.yml Normal file
View File

@@ -0,0 +1,74 @@
comment: >-
Generates a link for a given named link or url. The shortcode supports a
single unnamed parameter, or various named parameters. The unnamed parameter
is recognized as a url if it starts with "http", else it is treated as either
a named link or internal reference (in that order). Any inner text is rendered
as the link title, otherwise it uses the host name (for external links), link
title (for internal links), or anchor name (for any local references
containing a "#").
arguments:
page:
type:
- '*hugolib.pageState'
- '*hugolib.pageForShortcode'
optional: false
group: partial
comment: Context of the current page.
destination:
type: string
optional: false
group: partial
comment: >-
Target destination.
href:
type: string
position: 0
optional: true
comment: >-
Reference to either an external link (if it starts with http), a named
link (if it can be found in params.links), or internal reference.
Both external and internal references may include an anchor "#".
name:
type: string
optional: true
comment: Alias of href.
url:
type: string
optional: true
comment: Alias of href.
cue:
type: bool
optional: true
comment: >-
Flag to indicate if an external link should show a visual cue, defaults to
setting "main.externalLinks.cue" in the site's parameters.
tab:
type: bool
optional: true
comment: >-
Flag to indicate if an external link should open in a new tab, defaults to
setting "main.externalLinks.tab" in the site's parameters.
case:
type: bool
optional: true
default: true
comment: >-
Flag to indicate if the retrieved title (e.g. no inner text is provided)
of an internal link should use its original case. If false, the title is
set to lower case.
class:
type: string
optional: true
comment: Class attribute of the anchor element.
text:
type:
- string
- template.HTML
optional: true
group: partial
comment: Link title.
body:
type: string
optional: true
group: shortcode
comment: Link title.

27
data/structures/mark.yml Normal file
View File

@@ -0,0 +1,27 @@
comment: Highlights text by applying a background color.
arguments:
class:
type: string
optional: true
comment: Class attribute of the highlight element.
color:
type: select
optional: true
comment: >-
Theme color of the highlight. By default, the highlight uses the color of
the HTML mark function.
options:
values:
- primary
- secondary
- success
- danger
- warning
- info
- light
- dark
- white
- black
body:
optional: false
comment: Text to be marked.

View File

@@ -0,0 +1,56 @@
comment: >-
Defines an individual nav item.
arguments:
id:
type: string
optional: true
comment: ID of the nav-item.
parent: cascade
parentID:
type: string
optional: false
comment: ID of the parent (e.g. nav control).
group: partial
header:
type: string
optional: false
comment: Header of the nav item.
show:
type: bool
optional: true
comment: >-
Flag to indicate the nav item should be shown. Only one can be shown at a
time.
disabled:
type: bool
optional: true
comment: Flag to indicate the item should be in a disabled state.
fade:
type: bool
optional: true
comment: Flag to make the tab pane fade in.
parent: cascade
class:
type: string
optional: true
comment: Class attribute of the nav item.
body:
type:
- string
- template.HTML
optional: true
comment: The body content of the nav-item, supports Markdown and HTML (if enabled).
group: partial
item_type:
type: select
optional: true
comment: Type of the item to render.
options:
values:
- accordion
- tab-pane
group: partial
body:
optional: false
comment: Content of the nav item.
group: shortcode

82
data/structures/nav.yml Normal file
View File

@@ -0,0 +1,82 @@
comment: >-
Displays a tab group of multiple items. Add nav-item inner elements for each
tab pane.
arguments:
id:
type: string
optional: true
comment: >-
Identifier of the tab group, uses a generated sequence if not specified.
page:
type:
- '*hugolib.pageState'
- '*hugolib.pageForShortcode'
optional: false
comment: Context of the current page.
group: partial
list:
type:
- page.Pages
- resource.Resources
optional: true
comment: Array of pages to be rendered as nav items.
group: partial
type:
type: select
optional: true
comment: Type of the tab group.
options:
values:
- tabs
- pills
- underline
- callout
vertical:
type: bool
default: false
optional: true
comment: Flag to show vertical tabs instead of horizontal tabs.
wrap:
type: bool
default: false
optional: true
comment: Flag to enable word wrapping of tab titles.
class:
type: string
optional: true
comment: Class attribute of the tab group, e.g. “nav-fill”.
pane:
type: select
optional: true
default: none
comment: Style of the panes.
options:
values:
- none
- persona
group: partial
width:
type: select
optional: true
default: 100
comment: Responsive width of the tab group.
options:
values:
- 50
- 100
group: partial
loading:
type: select
optional: true
default: eager
parent: cascade
comment: >-
Loading behavior of the image. The loading of lazily loaded images is
deferred until the image is within scrolling range of the viewport. This
should reduce the initial loading time of the website. It is recommended
to lazily load only those images that are below the page fold.
options:
values:
- lazy
- eager
group: partial

102
data/structures/navbar.yml Normal file
View File

@@ -0,0 +1,102 @@
comment: >-
Displays a navigation header with a toggler. The menu items are derived from
the site's configuration. Nested items are supported at one-level depth. The
navigation bar includes a search area and a language switcher if applicable.
arguments:
page:
type:
- '*hugolib.pageState'
- '*hugolib.pageForShortcode'
optional: false
comment: Context of the current page.
group: partial
path:
type: path
optional: false
comment: Path of the active page.
group: shortcode
title:
type: string
optional: true
comment: >-
Brand title, displayed when the logo is not set. Defaults to the site's
title.
class:
type: string
optional: true
comment: Class attribute of the navbar container.
color:
type: select
optional: true
comment: Background theme color of the navbar.
options:
values:
- primary
- secondary
- success
- danger
- warning
- info
- light
- dark
- white
- black
- body
- body-tertiary
id:
type: string
optional: true
comment: >-
ID of the navbar, defaults to "navbar-0". The id is used by several child
elements, including a color mode switcher, version switcher, and collapse
panel.
menus:
type: string
optional: true
default: main
comment: Name of the menu configuration.
size:
type: select
optional: true
comment: Breakpoint of the navbar toggler.
default: md
options:
values:
- xs
- sm
- md
- lg
- xl
style:
type: select
optional: true
default: light
comment: Style of the navbar.
options:
values:
- light
- dark
mode:
type: bool
optional: true
default: true
comment: >-
Flag to include a color mode switcher, defaults to "true" when dark mode
is enabled.
search:
type: bool
optional: true
default: true
comment: Flag to include a search input.
fixed:
type: bool
optional: true
default: false
comment: Flag to indicate the navbar should stick to the top.
group: partial
logo:
type: path
optional: true
comment: >-
Address of the logo image, defaults to the parameter "logo" set in the
"main" section of the site's parameter configuration.

View File

@@ -0,0 +1,60 @@
comment: >-
Display a custom persona card.
arguments:
path:
type: path
optional: true
comment: >-
Path of the page that defines the card content. You can set "title",
"href", "thumbnail" and the inner content individually too.
title:
type:
- string
- template.HTML
optional: true
comment: Title of the card.
class:
type: string
optional: true
comment: Class attribute of the card element, e.g. “w-50”.
color:
type: select
optional: true
default: primary
comment: Theme color of the element.
options:
values:
- primary
- secondary
- success
- danger
- warning
- info
- light
- dark
- white
- black
- body
- body-tertiary
href:
type:
- string
- template.URL
optional: true
comment: Address for the button or hyperlink.
content:
type:
- string
- template.HTML
optional: true
comment: Content of the card.
group: partial
thumbnail:
type: url
optional: true
comment: Thumbnail image url, displayed on top or the left of the card.
body:
optional: true
comment: >-
Description of the card.
group: shortcode

View File

@@ -0,0 +1,39 @@
comment: >-
Displays a release button that links to a specific release. Use the state to
indicate if it is a new or deprecated feature.
arguments:
version:
type: string
optional: false
comment: Version string, expects semver notation with a "v" prefix.
state:
type: select
optional: true
default: new
comment: State of the feature.
options:
values:
- new
- deprecated
short:
type: bool
optional: true
comment: Flag to indicate the release button should use short notation.
size:
type: select
optional: true
default: md
comment: Size of the button
options:
values:
- sm
- md
- lg
class:
type: string
optional: true
comment: Class attribute of the button element.
inline:
type: bool
optional: true
comment: Flag to render the release button inline (defaults to false).

View File

@@ -0,0 +1,36 @@
comment: >-
Use the spinner shortcode to indicate the loading state of a component or
page. The inner content is used as alternative description.
arguments:
class:
type: string
optional: true
comment: >-
Class attribute of the wrapping element, e.g. “text-center”.
color:
type: select
optional: true
default: primary
comment: >-
Theme color of the element.
options:
values:
- primary
- secondary
- success
- danger
- warning
- info
- light
- dark
- white
- black
grow:
type: bool
optional: true
default: false
comment: Flag to indicate the spinner is growing instead of rotating.
body:
optional: false
comment: >-
Alternative description.

8
data/structures/sub.yml Normal file
View File

@@ -0,0 +1,8 @@
comment: >-
Displays text in subscript.
arguments:
text:
type: string
optional: false
position: 0
comment: Text to display in subscript.

8
data/structures/sup.yml Normal file
View File

@@ -0,0 +1,8 @@
comment: >-
Displays text in superscript.
arguments:
text:
type: string
optional: false
position: 0
comment: Text to display in superscript.

View File

@@ -344,6 +344,24 @@ As an example, the following shortcode displays a light navigation header.
{{< /example >}}
<!-- markdownlint-enable MD037 -->
## Persona
As an example, the following shortcode displays a persona card with a primary color.
<!-- markdownlint-disable MD037 -->
{{< example lang="hugo" >}}
{{</* persona thumbnail="/img/creator-1x1.jpg" title="Creators" color="primary" */>}}
As a content creator you value your independence. You like to take control of your
online and offline presence. You want to focus on growing your audience, without
limitations.
Hinode gives you the tools to publish your blog in the way that you want. You have
full ownership and control of your content. That is why content creators choose
Hinode.
{{</* /persona */>}}
{{< /example >}}
<!-- markdownlint-enable MD037 -->
## Release
As an example, the following shortcode displays a default release button.

View File

@@ -1,9 +1,20 @@
{{ $destination := .destination }}
{{- if not $destination -}}
{{- errorf "partial [utilities/link.html] - Missing param 'destination'" -}}
{{- end -}}
<!--
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "link" "args" . "group" "partial") }}
{{ errorf "partial [assets/link.html] - Invalid arguments" -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $destination := .destination }}
{{- $error := false -}}
{{- $target := "" -}}
{{- $rel := "" -}}
{{- $case := .case | default true }}
@@ -15,6 +26,7 @@
{{- $text := .text -}}
{{- $class := .class -}}
<!-- Main code -->
{{- if $isExternal -}}
{{- if not $text -}}
{{- $text = (urls.Parse (absURL $destination)).Host -}}
@@ -33,7 +45,7 @@
{{- if strings.Contains $destination "#" }}
{{ $segments := split $destination "#" }}
{{- if ne (len $segments) 2 }}
{{- errorf "partial [utilities/link.html] - Malformed path, expected one anchor '#' only: %s" $destination -}}
{{- errorf "partial [assets/link.html] - Malformed path, expected one anchor '#' only: %s" $destination -}}
{{ else }}
{{- $destination = index $segments 0 -}}
{{- $anchor = index $segments 1 -}}
@@ -42,7 +54,7 @@
{{ $ref := partial "utilities/GetPage.html" (dict "url" $destination "page" $page) }}
{{- if not $ref -}}
{{- errorf "partial [utilities/link.html] - Cannot find page: %s" $destination -}}
{{- errorf "partial [assets/link.html] - Cannot find page: %s" $destination -}}
{{- $error = true -}}
{{- else -}}
{{- $destination = $ref.RelPermalink -}}

View File

@@ -1,19 +1,19 @@
<!--
Defines an individual nav item. The shortcode supports the following arguments:
"id" Required unique ID of the nav-item.
"parentID" Required ID of the parent (e.g. nav control).
"class" Optional class attributes to be added to the nav-item.
"fade" Optional flag to make the tab pane fade in.
"header" Required header of the nav item.
"class" Optional class attribute of the nav item.
"body" The body content of the nav-item, supports Markdown and HTML (if enabled).
"show" Optional flag to indicate the item should be shown as expanded (only one can be shown at a time).
"disabled" Optional flag to indicate the item should be in a disabled state.
"type" Optional type of the item to render, supports "accordion" as alternative format. Defaults to
"tab-pane".
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "nav-item" "args" . "group" "partial") }}
{{ errorf "partial [assets/nav-item.html] - Invalid arguments" -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{- $id := .id -}}
{{- $parentID := .parentID -}}
{{- $class := .class -}}
@@ -23,9 +23,10 @@
{{- $body := .body -}}
{{- $show := .show -}}
{{- $disabled := .disabled -}}
{{- $type := .type -}}
{{- $type := .item_type -}}
{{- $illustration := .illustration -}}
<!-- Main code -->
{{ if eq $type "accordion" }}
<div class="accordion-item{{ if $show }} show{{ end }}{{ with $class }} {{ . }}{{ end }}">
{{- with $header -}}

View File

@@ -1,98 +1,47 @@
<!--
Displays a tab group of multiple items. Each provided page resource is rendered as a tab pane. The shortcode
supports the following arguments:
"page" Required context of the current page.
"list" Required array of pages.
"title" Optional title of the tab group.
"type" Optional type of the tab group, either "tabs", "pills" (default), "underline" or "callout".
"vertical" Optional flag to show vertical tabs instead of horizontal tabs (default).
"class" Optional class attribute of the tab group, e.g. “nav-fill”.
"pane" Optional style of the panes, either "none" (default) or "persona".
"width" Optional responsive width of the tab group, either "50" or "100" (default).
"wrap" Optional flag to enable word wrapping of tab titles, defaults to false.
In addition, the following arguments are passed to the individual tabs.
"class" Optional class attribute of the tab element, e.g. “w-50”.
"color": Optional theme color of the tab, either "primary", "secondary", "success", "danger",
"warning", "info", "light", "dark", or "body". By default, no color is specified.
-->
<!--
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "nav" "args" . "group" "partial") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{- $page := .page -}}
{{- if ne (printf "%T" $page) "*hugolib.pageState" -}}
{{- errorf "partial [assets/nav.html] - Invalid value for param 'page'" -}}
{{- end -}}
{{- $id := "0" -}}
{{- with .id -}}
{{ $id = . }}
{{ end }}
{{- $supportedTypes := slice "page.Pages" "resource.Resources" -}}
{{- $id := .id | default "0" -}}
{{ $list := .list }}
{{- if not (in $supportedTypes (printf "%T" $list)) -}}
{{- errorf "partial [assets/nav.html] - Invalid value for param 'list'" -}}
{{- end -}}
{{ $pane := "none" }}
{{ with .pane }}
{{- $supportedPanes := slice "none" "persona" -}}
{{- $pane = . }}
{{- if not (in $supportedPanes $pane) -}}
{{- errorf "partial [assets/nav.html] - Invalid value for param 'pane'" -}}
{{- end -}}
{{ end }}
{{ $supportedWidths := slice 50 100 -}}
{{ $widthParam := 100 -}}
{{ $width := 100 }}
{{ with .width }}{{ $widthParam = . }}{{ end -}}
{{ if in $supportedWidths $widthParam -}}
{{ $width = int $widthParam }}
{{ else -}}
{{ errorf "partial [assets/nav.html] - Invalid value for param 'width': %s" $widthParam -}}
{{ end -}}
{{ $pane := .pane | default "none" }}
{{ $width := .width | default 100 }}
{{- $title := .title -}}
{{- $class := .class -}}
{{- $color := .color -}}
{{- $wrap := .wrap | default false -}}
{{ $vertical := .vertical | default false }}
{{ $type := .type | default "pills" }}
{{- $loading := .loading | default "eager" -}}
{{ $supportedFlags := slice "true" "false" -}}
{{ $verticalParam := "false" -}}
{{ $vertical := false }}
{{ with .vertical }}{{ $verticalParam = . }}{{ end -}}
{{ if in $supportedFlags $verticalParam -}}
{{ if eq $verticalParam "true" }}{{ $vertical = true }}{{ else }}{{ $vertical = false }}{{ end -}}
{{ else -}}
{{ errorf "partial [assets/nav.html] - Invalid value for param 'vertical': %s" $verticalParam -}}
{{ end -}}
{{ $type := "pills" }}
{{ with .type }}
{{ $type = . -}}
{{ $supportedNavTypes := slice "tabs" "pills" "underline" "callout" -}}
{{ if $type }}
{{ if not (in $supportedNavTypes $type) -}}
{{ errorf "partial [assets/nav.html] - Invalid value for param 'type': %s" $type -}}
{{ end -}}
{{ end -}}
{{ end -}}
{{- $loading := .loading -}}
{{- $validSettings := slice "lazy" "eager" -}}
{{- if $loading -}}
{{ if not (in $validSettings $loading) -}}
{{- errorf "partial [assets/nav.html] - Invalid value for param 'loading': %s" $loading -}}
{{ end -}}
{{- end -}}
<!-- Main code -->
<div class="{{ if eq $width 50 }}col-sm-12 col-md-10 col-lg-8 col-xl-6{{ else }}col-12{{ end }} mx-auto">
{{ if $vertical }}<div class="d-flex align-items-start">{{ end }}
{{ if eq $type "callout" }}
<div class="d-lg-none">
<div id="accordion-{{ $id }}" class="accordion mb-3{{ with $class }} {{ . }}{{ end }} nav-callout">
{{- range $index, $item := $list -}}
{{ partial "assets/nav-item" (dict
{{ partial "assets/nav-item.html" (dict
"id" $index
"parentID" $id
"fade" false
@@ -101,7 +50,7 @@
"body" (or $item.Description $item.Content)
"show" false
"disabled" false
"type" "accordion"
"item_type" "accordion"
"illustration" (partial "utilities/GetIllustration.html" (dict "item" $item "size" "col-12"))
)
}}

View File

@@ -1,22 +1,17 @@
<!--
Displays a navigation header with a toggler. The partial supports the following arguments:
"id" Optional id of the navbar, defaults to "navbar-0". The id is used by several child elements,
including a color mode switcher, version switcher, and collapse panel.
"page" Required object reference to the current page.
"menus" Optional name of the menu configuration, defaults to "main".
"size" Optional breakpoint of the navbar toggler, either "xs", "sm", "md" (default), "lg", or "xl".
"fixed" Optional flag to indicate the navbar should stick to the top, defaults to false.
"color" Optional background color of the navbar, either "primary", "secondary", "success",
"danger", "warning", "info", "white", "black", "body", or "body-tertiary". The default color is
none.
"mode" Optional flag to include a color mode switcher, default is "true" (if dark mode is enabled).
"search" Optional flag to include a search input, default is "true".
"logo" Optional address of the logo image, defaults to the parameter "logo" set in the "main" section of
the site's parameter configuration.
"title" Optional brand title, displayed when the logo is not set. Defaults to the site's title.
"class" Optional class attribute of the navbar container.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "navbar" "args" . "group" "partial") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Inline partial to render the color mode switcher -->
{{- define "partials/navbar-mode.html" -}}
{{- $size := .size -}}
@@ -97,22 +92,13 @@
</li>
{{- end -}}
<!-- Initialize arguments -->
{{- $absoluteURL := site.Params.main.canonifyAssetsURLs | default false -}}
{{- $supportedFlags := slice "true" "false" -}}
{{- $id := printf "navbar-%d" 0 -}}
{{ with .id }}
{{ $id = . }}
{{ end }}
{{- $id := .id | default (printf "navbar-%d" 0) -}}
{{- $page := .page -}}
{{- if not $page -}}
{{- errorf "partial [assets/navbar.html] - Missing value for param 'page'" -}}
{{- end -}}
{{- $defaultMenu := "main" }}
{{- $menuName := $defaultMenu }}
{{- with .menus }}{{ $menuName = . }}{{ end -}}
{{- $defaultMenu := "main" -}}
{{- $menuName := .menus | default $defaultMenu }}
{{- $menus := index site.Menus $menuName -}}
{{- if or (ne (printf "%T" $menus) "navigation.Menu") (ne (index $menus 0).Menu $menuName) -}}
{{- if ne $menuName $defaultMenu }}
@@ -120,51 +106,12 @@
{{- end -}}
{{- end -}}
{{- $size := "md" -}}
{{- with .size }}{{ $size = . }}{{ end -}}
{{- $supportedSizes := slice "xs" "sm" "md" "lg" "xl" -}}
{{- if not (in $supportedSizes $size) -}}
{{- errorf "partial [assets/navbar.html] - Invalid value for param 'size': %s" $size -}}
{{- end -}}
{{- $fixedParam := "false" -}}
{{- $fixed := false -}}
{{- with .fixed }}{{ $fixedParam = . }}{{ end -}}
{{- if in $supportedFlags $fixedParam -}}
{{- if eq $fixedParam "true" }}{{ $fixed = true }}{{ else }}{{ $fixed = false }}{{ end -}}
{{- else -}}
{{- errorf "partial [assets/navbar.html] - Invalid value for param 'fixed': %s" $fixedParam -}}
{{- end -}}
{{- $color := "" -}}
{{- with .color -}}
{{- $color = . -}}
{{- $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "white" "black" "body" "body-tertiary" -}}
{{- if not (in $supportedColors $color) -}}
{{- errorf "partial [assets/navbar.html] - Invalid value for param 'color': %s" $color -}}
{{- end -}}
{{- end -}}
{{- $search := default true site.Params.navigation.search -}}
{{- with .search -}}
{{- $searchParam := . -}}
{{- if in $supportedFlags $searchParam -}}
{{- if eq $searchParam "true" }}{{ $search = true }}{{ else }}{{ $search = false }}{{ end -}}
{{- else -}}
{{- errorf "partial [assets/navbar.html] - Invalid value for param 'search': %s" $searchParam -}}
{{- end -}}
{{- end -}}
{{- $size := .size | default "md" -}}
{{- $fixed := .fixed | default false -}}
{{- $color := .color | default "" -}}
{{- $search := .search | default site.Params.navigation.search -}}
{{- $searchModal := and $search site.Params.navigation.searchModal -}}
{{- $enableDarkMode := default false site.Params.main.enableDarkMode -}}
{{- with .mode -}}
{{- $darkModeParam := . -}}
{{- if in $supportedFlags $darkModeParam -}}
{{- if eq $darkModeParam "true" }}{{ $enableDarkMode = site.Params.main.enableDarkMode }}{{ else }}{{ $enableDarkMode = false }}{{ end -}}
{{- else -}}
{{- errorf "partial [assets/navbar.html] - Invalid value for param 'darkMode': %s" $darkModeParam -}}
{{- end -}}
{{- end -}}
{{- $enableDarkMode := .mode | default site.Params.main.enableDarkMode -}}
{{- $enableVersions := false -}}
{{ $list := site.Params.docs.releases }}
@@ -173,15 +120,11 @@
{{ end }}
{{- $enableLanguage := or $page.IsTranslated site.IsMultiLingual -}}
{{- $horizontal := default false site.Params.navigation.horizontal -}}
{{- $logo := site.Params.navigation.logo -}}
{{- $logo := .logo | default site.Params.navigation.logo -}}
{{- $logoLight := "" -}}
{{- $logoDark := "" -}}
{{- with .logo }}
{{ $logo = . }}
{{- end -}}
{{- if $enableDarkMode -}}
{{ $ext := path.Ext $logo -}}
{{- $logoLight = printf "%s-light%s" (strings.TrimSuffix $ext $logo) $ext -}}
@@ -222,6 +165,7 @@
{{- $contrast := false -}}
{{- if in (slice "primary" "secondary" "success" "danger") $color }}{{ $contrast = true }}{{ end -}}
<!-- Main code -->
<div class="container-fluid {{ if $fixed }}fixed-top{{ end }} p-0{{ with $class }} {{ . }}{{ end }}">
{{- partial "assets/page-alert.html" (dict "page" $page) -}}
<nav class="navbar {{ if $fixed }}navbar-fixed-top{{ end }} navbar-expand-{{ $size }}{{ if $contrast }} navbar-contrast{{ end }}{{ with $color }} bg-{{ . }}{{ end }} p-4"{{ with $theme }} data-bs-theme="{{ . }}"{{ end }}>

View File

@@ -1,30 +1,18 @@
<!--
Displays a custom persona card. Either specify a valid path, or set the arguments title, href, content, and
thumbnail individually. The latter arguments override any page attributes.
The shortcode supports the following arguments:
"path" Optional path of the page, override with other parameters.
"title" Required title of the card.
"href" Optional address for the button or hyperlink.
"class" Optional class attribute of the card element, e.g. “w-50”.
"color": Optional theme color of the card, either "primary", "secondary", "success", "danger",
"warning", "info", "light", "dark", "white", "black", "body", or "body-tertiary". By default, no
color is specified.
"content" Optional content of the card.
"thumbnail" Optional thumbnail image url, displayed on top or the left of the card.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
<!-- Inline partial to render the card's body -->
{{- define "partials/persona-body.html" -}}
{{- $title := .title -}}
{{- $href := .href -}}
{{- $color := .color -}}
{{- $content := .content -}}
<h3>{{ $title }}</h3>
{{ with $content }}<p>{{ . }}</p>{{ end -}}
{{- end -}}
{{ $error := false }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "persona" "args" . "group" "partial") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{- $page := "" }}
{{- if .path }}
{{- $page = site.GetPage .path }}
@@ -38,14 +26,7 @@
{{- $content := .content -}}
{{- $thumbnail := .thumbnail -}}
{{- $color := "" -}}
{{- with .color }}{{ $color = . }}{{ end -}}
{{- if $color -}}
{{- $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "white" "black" "body" "body-tertiary" -}}
{{- if not (in $supportedColors $color) -}}
{{- errorf "partial [assets/persona.html] - Invalid value for param 'color': %s" $color -}}
{{- end -}}
{{- end -}}
{{- $color := .color -}}
{{- with $page -}}
{{- if not $title }}{{ $title = .Title }}{{ end -}}
@@ -55,48 +36,68 @@
{{- end -}}
{{- $class := .class -}}
{{- $loading := .loading -}}
{{- $validSettings := slice "lazy" "eager" -}}
{{- if $loading -}}
{{ if not (in $validSettings $loading) -}}
{{- errorf "partial [assets/persona.html] - Invalid value for param 'loading': %s" $loading -}}
{{ end -}}
{{- $tab := site.Params.main.externalLinks.tab -}}
{{- $isExternal := ne (urls.Parse (absURL $href)).Host (urls.Parse site.BaseURL).Host -}}
{{- $target := "" -}}
{{- $rel := "" -}}
{{- if and $isExternal $tab -}}
{{- $target = "_blank" -}}
{{- $rel = "noopener noreferrer" -}}
{{- end -}}
<div class="d-none d-md-block">
<div class="persona position-relative row mt-5 align-middle p-3">
<div class="col-2">
<div class="position-absolute top-50 start-0 translate-middle-y col-4 ps-3">
{{- if $thumbnail -}}
{{- partial "assets/image.html" (dict "url" $thumbnail "title" $title "ratio" "1x1" "innerClass" "rounded-5" "loading" $loading) -}}
{{ end }}
<!-- Inline partial to render the card's body -->
{{- define "partials/persona-body.html" -}}
{{- $title := .title -}}
{{- $content := .content -}}
<h3>{{ $title }}</h3>
{{ with $content }}<p>{{ . }}</p>{{ end -}}
{{- end -}}
<!-- Main code -->
{{- if not $error -}}
{{ with $href }}
<a href="{{ . }}" aria-label="{{ $title | safeHTML }}"
{{- with $target }} target="{{ . }}"{{ end }}
{{ with $rel }} rel="{{ . }}"{{ end -}}
>
{{ end }}
<div class="d-none d-md-block">
<div class="persona position-relative row mt-5 align-middle p-3">
<div class="col-2">
<div class="position-absolute top-50 start-0 translate-middle-y col-4 ps-3">
{{- if $thumbnail -}}
{{- partial "assets/image.html" (dict "url" $thumbnail "title" $title "ratio" "1x1" "innerClass" "rounded-5" "loading" $loading) -}}
{{ end }}
</div>
</div>
</div>
<div class="col-10 {{ with $color }}bg-{{ . }} text-bg-{{ . }}{{ end }} rounded-5 fs-md-5 fs-6 pe-5 pb-3">
<div class="row">
<div class="col-3"></div>
<div class="col-9">
{{- partial "persona-body.html" (dict "title" $title "href" $href "color" $color "content" $content) -}}
<div class="col-10 {{ with $color }}bg-{{ . }} text-bg-{{ . }}{{ end }} rounded-5 fs-md-5 fs-6 pe-5 pb-3">
<div class="row">
<div class="col-3"></div>
<div class="col-9">
{{- partial "persona-body.html" (dict "title" $title "content" $content) -}}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="d-md-none">
<div class="persona position-relative row mt-5 align-middle p-3 ptw-5">
<div class="col-12">
<div class="position-absolute top-25 start-50 translate-middle col-6">
{{- if $thumbnail -}}
{{- partial "assets/image.html" (dict "url" $thumbnail "title" $title "ratio" "1x1" "innerClass" "rounded-5" "loading" $loading) -}}
{{ end }}
<div class="d-md-none">
<div class="persona position-relative row mt-5 align-middle p-3 ptw-5">
<div class="col-12">
<div class="position-absolute top-25 start-50 translate-middle col-6">
{{- if $thumbnail -}}
{{- partial "assets/image.html" (dict "url" $thumbnail "title" $title "ratio" "1x1" "innerClass" "rounded-5" "loading" $loading) -}}
{{ end }}
</div>
</div>
</div>
<div class="col-12 {{ with $color }}bg-{{ . }} text-bg-{{ . }}{{ end }} rounded-5 ptw-lg-5 ptw-3 ptw-sm-4 fs-md-5 fs-6 pb-3">
<div class="p-5">
{{- partial "persona-body.html" (dict "title" $title "href" $href "color" $color "content" $content) -}}
<div class="col-12 {{ with $color }}bg-{{ . }} text-bg-{{ . }}{{ end }} rounded-5 ptw-lg-5 ptw-3 ptw-sm-4 fs-md-5 fs-6 pb-3">
<div class="p-3">
{{- partial "persona-body.html" (dict "title" $title "content" $content) -}}
</div>
</div>
</div>
</div>
</div>
{{ if $href }}</a>{{ end }}
{{ end }}

View File

@@ -71,7 +71,7 @@
<li>
{{ $class := "sidebar-item text-decoration-none rounded" }}
{{ if $active }}{{ $class = printf "%s active" $class }}{{ end }}
{{ $link := partial "utilities/link.html" (dict "destination" $href "text" $title "class" $class "page" $page) }}
{{ $link := partial "assets/link.html" (dict "destination" $href "text" $title "class" $class "page" $page) }}
{{ if $link }}
{{ print $link | safeHTML }}
{{ else }}
@@ -84,7 +84,7 @@
<li>
{{ $class := "sidebar-item text-decoration-none rounded small" }}
{{ if $active }}{{ $class = printf "%s active" $class }}{{ end }}
{{ $link := partial "utilities/link.html" (dict "destination" $href "text" $title "class" $class "page" $page) }}
{{ $link := partial "assets/link.html" (dict "destination" $href "text" $title "class" $class "page" $page) }}
{{ if $link }}
{{ print $link | safeHTML }}
{{ else }}

View File

@@ -5,7 +5,7 @@
{{ cond (gt (len .Site.Copyright) 0) .Site.Copyright $copyright }}
{{ .Site.Params.footer.license | safeHTML }}
{{ if .Site.Params.main.endorse }}
{{ $link := partial "utilities/link" (dict "destination" (index site.Params.links "hinode") "text" "Hinode" "class" "link-bg-footer") }}
{{ $link := partial "assets/link.html" (dict "destination" (index site.Params.links "hinode") "text" "Hinode" "class" "link-bg-footer" "page" .Page) }}
{{ T "poweredBy" $link | safeHTML }}
{{ end }}
</small>

View File

@@ -9,14 +9,14 @@
{{- $thumbnail = $page.Params.Thumbnail.url -}}
{{- $author := "" -}}
{{- if and $page.Params.Thumbnail.authorURL "text" $page.Params.Thumbnail.author }}
{{- $author = partial "utilities/link" (dict "destination" $page.Params.Thumbnail.authorURL "text" $page.Params.Thumbnail.author) -}}
{{- $author = partial "assets/link.html" (dict "destination" $page.Params.Thumbnail.authorURL "text" $page.Params.Thumbnail.author "page" $page) -}}
{{- else if $page.Params.Thumbnail.author }}
{{- $author = $page.Params.Thumbnail.author -}}
{{- end -}}
{{- $origin := "" -}}
{{- if and $page.Params.Thumbnail.originURL "text" $page.Params.Thumbnail.origin }}
{{- $origin = partial "utilities/link" (dict "destination" $page.Params.Thumbnail.originURL "text" $page.Params.Thumbnail.origin) -}}
{{- $origin = partial "assets/link.html" (dict "destination" $page.Params.Thumbnail.originURL "text" $page.Params.Thumbnail.origin "page" $page) -}}
{{- else if $page.Params.Thumbnail.origin }}
{{- $origin = $page.Params.Thumbnail.origin -}}
{{- end }}

View File

@@ -36,7 +36,6 @@
{{ end }}
{{ $group := .group }}
{{ $namedArgs := true }}
{{ if not $error }}
@@ -51,6 +50,13 @@
{{ end }}
{{ end }}
{{ if $def }}
{{ $groups := slice | append $def.group }}
{{ if and $group $def.group }}
{{ if not (in $groups $group )}}{{ $def = "" }}{{ end }}
{{ end }}
{{ end }}
{{ if not $def }}
{{ if eq (printf "%T" $key) "string" }}
{{ warnf "[%s] unsupported argument '%s'" $structure $key }}
@@ -73,20 +79,20 @@
{{ if $extra }}{{ $expected = $expected | append $extra }}{{ end }}
{{ $actual := printf "%T" $val }}
{{/* cast supported types from string */}}
{{/* cast supported types from/to string */}}
{{ if and (in $expected "bool") (in (slice "true" "false") $val) }}
{{ $actual = "bool" }}
{{ else if and (in $expected "int") (findRE `^-?\d+$` $val) }}
{{ $actual = "int" }}
{{ else if and (in $expected "float") (findRE `^(?:[1-9]\d*|0)?(?:\.\d+)?$` $val) }}
{{ $actual = "float" }}
{{ else if and (in $expected "string") (in (slice "bool" "int" "float" "float64") $actual) }}
{{ $actual = "string" }}
{{ end }}
{{ if $val }}
{{ if not (in $expected $actual ) }}
{{ warnf "[%s] argument '%s': expected type '%s', got '%s'" $structure (string $key) (delimit $expected ", ") $actual }}
{{ $error = true }}
{{ end }}
{{ if and $val (not (in $expected $actual)) }}
{{ warnf "[%s] argument '%s': expected type '%s', got '%s'" $structure (string $key) (delimit $expected ", ") $actual }}
{{ $error = true }}
{{ end }}
{{/* validate permitted values */}}

View File

@@ -1,24 +1,18 @@
<!--
Generates a link for a given named link or url. The shortcode supports a single unnamed parameter, or various named
parameters. The unnamed parameter is recognized as a url if it starts with "http", else it is treated as either a
named link or internal reference (in that order). Any inner text is rendered as the link title, otherwise it uses
the host name (for external links), link title (for internal links), or anchor name (for any local references
containing a `#`). The shortcode supports the following named arguments:
"href" Required reference to either an external link (if it starts with http), a named link (if it can be
found in params.links), or internal reference. External and internal references may include an
anchor "#".
"name" Alias of href.
"url" Alias of href.
"cue" Optional flag to indicate if an external link should show a visual cue, defaults to setting
"main.externalLinks.cue" in the site's parameters.
"tab" Optional flag to indicate if an external link should open in a new tab, defaults to setting
"main.externalLinks.tab" in the site's parameters.
"case" Optional flag to indicate if the retrieved title (e.g. no inner text is provided) of an internal
link should use its original case, defaults to true. If false, the title is set to lower case.
"class" Optional class attribute of the anchor element.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $error := false -}}
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "link" "args" .Params "group" "shortcode") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $href := "" }}
{{ $name := "" }}
{{ $url := "" }}
@@ -84,6 +78,7 @@
{{ $url = printf "%s#%s" $url .}}
{{ end }}
<!-- Main code -->
{{- if not $error -}}
{{ partial "utilities/link.html" (dict "destination" $url "text" $text "cue" $cue "tab" $tab "case" $case "class" $class "page" .Page) }}
{{ partial "assets/link.html" (dict "destination" $url "text" $text "cue" $cue "tab" $tab "case" $case "class" $class "page" .Page) }}
{{- end -}}

View File

@@ -1,23 +1,24 @@
<!--
Highlights text by applying a background color. The shortcode supports the following arguments:
"color": Optional theme color of the highlight, either "primary", "secondary", "success", "danger",
"warning", "info", "light", "dark", "white" or "black". By default, the highlight uses the color of
the HTML mark function.
"class": Optional class attribute of the highlight element.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $error := false -}}
{{ $color := .Get "color" | default "" -}}
{{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" -}}
{{ if and $color (not (in $supportedColors $color)) -}}
{{ errorf "Invalid value for param 'color': %s" .Position -}}
{{ $error = true -}}
{{ end -}}
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "mark" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $color := .Get "color" | default "" -}}
{{- $class := .Get "class" | default "" -}}
{{- if $color }}{{ $class = printf "%s text-bg-%s" $class $color }}{{ end -}}
<!-- Main code -->
{{- if not $error -}}
{{- if $color }}{{ $class = printf "%s text-bg-%s" $class $color }}{{ end -}}
<mark{{ with $class }} class="{{ . }}"{{ end }}>{{ trim .Inner " \r\n" | .Page.RenderString -}}</mark>
{{- end -}}

View File

@@ -1,13 +1,19 @@
<!--
Defines an individual nav item. The shortcode supports the following arguments:
"header" Required header of the nav item.
"class" Optional class attribute of the inner nav item.
"show" Optional flag to indicate an item should be shown.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $current := "" }}
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "nav-item" "args" .Params "group" "shortcode") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ if not .Parent }}
{{ errorf "The nav-item shortcode should be contained within a nav shortcode: %s" .Position }}
{{ else }}
@@ -21,37 +27,14 @@
{{- if eq (.Parent.Get "fade") "true" -}}
{{- $fade = true -}}
{{- end -}}
{{- $type := .Parent.Get "type" -}}
{{- $header := .Get "header" | default "" -}}
{{- if not $header -}}
{{- errorf "Missing value for param 'header': %s" .Parent.Position -}}
{{- end -}}
{{- $class := .Get "class" | default "" -}}
{{- $body := trim .Inner " \r\n" | .Page.RenderString -}}
{{- $show := .Get "show" | default false -}}
{{- $disabled := .Get "disabled" | default false -}}
{{- $supportedFlags := slice "true" "false" -}}
{{- $showParam := "false" -}}
{{- $show := false -}}
{{- with .Get "show" }}{{ $showParam = . }}{{ end -}}
{{- if in $supportedFlags $showParam -}}
{{- if eq $showParam "true" }}{{ $show = true }}{{ else }}{{ $show = false }}{{ end -}}
{{- else -}}
{{- errorf "Invalid value for param 'show': %s" $showParam -}}
{{- end -}}
{{- $disabledParam := "false" -}}
{{- $disabled := false -}}
{{- with .Get "disabled" }}{{ $disabledParam = . }}{{ end -}}
{{- if in $supportedFlags $disabledParam -}}
{{- if eq $disabledParam "true" }}{{ $disabled = true }}{{ else }}{{ $disabled = false }}{{ end -}}
{{- else -}}
{{- errorf "Invalid value for param 'disabled': %s" $disabledParam -}}
{{- end -}}
{{ $output := partial "assets/nav-item" (dict
<!-- Main code -->
{{ $output := partial "assets/nav-item.html" (dict
"id" $id
"parentID" $parent
"fade" $fade
@@ -60,7 +43,6 @@
"body" $body
"show" $show
"disabled" $disabled
"type" $type
)
}}
@@ -80,7 +62,7 @@
"body" $body
"show" $show
"disabled" $disabled
"type" "accordion"
"item_type" "accordion"
)
}}

View File

@@ -1,49 +1,27 @@
<!--
Displays a tab group of multiple items. Add nav-item inner elements for each tab pane. The shortcode supports the
following arguments:
"type" Optional type of the tab group, either "tabs", "pills", "underline", or "callout".
"vertical" Optional flag to show vertical tabs instead of horizontal tabs (default).
"fade" Optional flag to make tab panes fade in.
"class" Optional class attribute of the tab group, e.g. “nav-fill”.
"wrap" Optional flag to enable word wrapping of tab titles, defaults to false.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $id := printf "nav-%d" .Ordinal -}}
{{ with .Get "id" }}
{{ $id = . }}
{{ $error := false }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "nav" "child" "nav-item" "args" .Params "group" "shortcode") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{- $id := .Get "id" | default (printf "nav-%d" .Ordinal) -}}
{{- $class := .Get "class" | default "" -}}
{{ $type := .Get "type" | default "" -}}
{{ $supportedNavTypes := slice "tabs" "pills" "underline" "callout" -}}
{{ if $type }}
{{ if not (in $supportedNavTypes $type) -}}
{{ errorf "Invalid value for param 'type': %s" $type -}}
{{ end -}}
{{ end -}}
{{ $supportedFlags := slice "true" "false" -}}
{{ $verticalParam := "false" -}}
{{ $vertical := false -}}
{{ with .Get "vertical" }}{{ $verticalParam = . }}{{ end -}}
{{ if in $supportedFlags $verticalParam -}}
{{ if eq $verticalParam "true" }}{{ $vertical = true }}{{ else }}{{ $vertical = false }}{{ end -}}
{{ else -}}
{{ errorf "Invalid value for param 'vertical': %s" $verticalParam -}}
{{- end -}}
{{ $fadeParam := "false" -}}
{{ with .Get "fade" }}{{ $fadeParam = . }}{{ end -}}
{{ if not (in $supportedFlags $fadeParam) -}}
{{ errorf "Invalid value for param 'fade': %s" $fadeParam -}}
{{- end -}}
{{ $wrapParam := "false" -}}
{{- $wrap := false -}}
{{ with .Get "wrap" }}{{ $wrapParam = . }}{{ end -}}
{{ if not (in $supportedFlags $wrapParam) -}}
{{ errorf "Invalid value for param 'wrap': %s" $wrapParam -}}
{{- end -}}
{{ with .Get "vertical" }}{{ $vertical = partial "utilities/CastBool.html" . }}{{ end -}}
{{ $wrap := false -}}
{{ with .Get "wrap" }}{{ $wrap = partial "utilities/CastBool.html" . }}{{ end -}}
{{- if and (eq $type "tabs") $vertical -}}
{{- errorf "Tabs do not support vertical layout" -}}
@@ -81,6 +59,7 @@
<div class="d-none d-lg-block">
{{ end }}
<!-- Main code -->
<div class="nav{{ with $type }} nav-{{ . }}{{ end }}{{ with $class }} {{ . }}{{ end }}{{ if $vertical }} flex-column{{ end }}" id="{{ $id }}" role="tablist"{{ if $vertical }} aria-orientation="vertical"{{ end }}>
{{ if $vertical }}<div class="row"><div class="col-auto">{{ end }}
{{- range $index, $item := $items -}}

View File

@@ -1,93 +1,42 @@
<!--
Displays a navigation header with a toggler. The menu items are derived from the site's configuration. Nested items
are supported at one-level depth. The navigation bar includes a search area and a language switcher if applicable.
The shortcode supports the following arguments:
"id" Optional id of the navbar toggler, defaults to "navbar-collapse-n" with a sequential number n
starting at 1.
"path" Required path of the active page.
"menus" Optional name of the menu configuration, defaults to "main".
"size" Optional breakpoint of the navbar toggler, either "xs", "sm", "md" (default), "lg", or "xl".
"style" Optional style of the navbar, either "light" (default) or "dark".
"color" Optional background color of the navbar, either "primary", "secondary", "success",
"danger", "warning", "info", "white", "black", "body", or "body-tertiary". The default color is
none.
"mode" Optional flag to include a color mode switcher, default is "true" (if dark mode is enabled).
"search" Optional flag to include a search input, default is "true".
"logo" Optional address of the logo image.
"title" Optional brand title, displayed when the logo is not set.
"class": Optional class attribute of the navbar container.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $error := false }}
{{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "white" "black" "body" "body" "body-tertiary" -}}
{{ $supportedFlags := slice "true" "false" -}}
{{- $id := printf "navbar-collapse-%d" (add .Ordinal 1) -}}
{{ with .Get "id" }}
{{ $id = . }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "navbar" "args" .Params "group" "shortcode") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
{{ $path := .Get "path" | default "" }}
{{ $page := .Site.GetPage $path }}
<!-- Initialize arguments -->
{{- $id := .Get "id" | default (printf "navbar-collapse-%d" (add .Ordinal 1)) -}}
{{ $path := .Get "path" }}
{{ $page := "" }}
{{ if $path }}{{ $page = .Site.GetPage $path }}{{ end }}
{{ if not $page }}
{{ errorf "Invalid or missing value for param 'path': %s" $path -}}
{{ errorf " - Location: %s" .Position -}}
{{ errorf "Cannot find page '%s': %s" $path .Position -}}
{{ $error = true -}}
{{ end }}
{{ $menus := "main" -}}
{{ with .Get "menus" }}{{ $menus = .}}{{ end -}}
{{ $size := "md" -}}
{{ with .Get "size" }}{{ $size = . }}{{ end -}}
{{ $supportedSizes := slice "xs" "sm" "md" "lg" "xl" -}}
{{ if not (in $supportedSizes $size) -}}
{{ errorf "Invalid value for param 'size': %s" $size -}}
{{ $error = true -}}
{{ end -}}
{{ $style := "light" -}}
{{ with .Get "style" }}{{ $style = . }}{{ end -}}
{{ $supportedStyles := slice "light" "dark" -}}
{{ if not (in $supportedStyles $style) -}}
{{ errorf "Invalid value for param 'style': %s" $style -}}
{{ $error = true -}}
{{ end -}}
{{ $menus := .Get "menus" | default "main" -}}
{{ $size := .Get "size" | default "md" -}}
{{ $style := .Get "style" | default "light" -}}
{{ $inverseStyle := "light" -}}
{{ if eq $style "light" }}{{ $inverseStyle = "dark" }}{{ end -}}
{{ $color := "" -}}
{{ with .Get "color" }}
{{ $color = . }}
{{ if not (in $supportedColors $color) -}}
{{ errorf "Invalid value for param 'color': %s" $color -}}
{{ $error = true -}}
{{ end -}}
{{ end -}}
{{ $searchParam := "true" -}}
{{ with .Get "search" }}{{ $searchParam = . }}{{ end -}}
{{ if not (in $supportedFlags $searchParam) -}}
{{ errorf "Invalid value for param 'search': %s" .Position -}}
{{ $error = true -}}
{{ end -}}
{{ $modeParam := "true" -}}
{{ with .Get "mode" }}{{ $modeParam = . }}{{ end -}}
{{ if not (in $supportedFlags $modeParam) -}}
{{ errorf "Invalid value for param 'mode': %s" .Position -}}
{{ $error = true -}}
{{ end -}}
{{ $logo := "" -}}
{{ with .Get "logo" }}{{ $logo = . }}{{ end -}}
{{ $title := "" -}}
{{ with .Get "title" }}{{ $title = . }}{{ end -}}
{{ $color := .Get "color" | default "" -}}
{{ $searchParam := true -}}
{{ with .Get "search" }}{{ $searchParam = partial "utilities/CastBool.html" . }}{{ end -}}
{{ $modeParam := true -}}
{{ with .Get "mode" }}{{ $modeParam = partial "utilities/CastBool.html" . }}{{ end -}}
{{ $logo := .Get "logo" | default "" -}}
{{ $title := .Get "title" | default "" -}}
{{- $class := .Get "class" | default "" -}}
<!-- Main code -->
{{ if not $error -}}
{{- partial "assets/navbar.html" (dict
"id" $id

View File

@@ -1,33 +1,41 @@
<!--
Displays a custom persona card. The shortcode supports the following arguments:
"path" Required path of the page.
"class" Optional class attribute of the card element, e.g. “w-50”.
"color": Optional theme color of the card, either "primary", "secondary", "success", "danger",
"warning", "info", "light", "dark", "white", "black", "body", or "body-tertiary". By default, no
color is specified.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $error := false -}}
{{ $error := false }}
{{- $path := .Get "path" | default "" -}}
{{- $page := .Site.GetPage $path -}}
{{- if not $page -}}
{{- errorf "Invalid or missing value for param 'path': %s" .Position -}}
{{- $error = true -}}
{{- end -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "persona" "args" .Params "group" "shortcode") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
{{- $class := .Get "class" | default "" -}}
{{- $color := "" -}}
{{- with .Get "color" }}{{ $color = . }}{{ end -}}
{{- if $color -}}
{{- $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "white" "black" "body" "body-tertiary" -}}
{{- if not (in $supportedColors $color) -}}
{{- errorf "Invalid value for param 'color': %s" .Position -}}
<!-- Initialize arguments -->
{{- $path := .Get "path" -}}
{{ if $path }}
{{- if not .Site.GetPage $path -}}
{{- errorf "Invalid or missing value for param 'path': %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{- end -}}
{{ end }}
{{- $class := .Get "class" | default "" -}}
{{- $color := .Get "color" | default "" -}}
{{- $title := .Get "title" -}}
{{- $href := .Get "href" -}}
{{- $content := trim .Inner " \r\n" | .Page.RenderString -}}
{{- $thumbnail := .Get "thumbnail" -}}
<!-- Main code -->
{{- if not $error -}}
{{- partial "assets/persona.html" (dict "path" $path "class" $class "color" $color) -}}
{{- end -}}
{{- partial "assets/persona.html" (dict
"path" $path
"class" $class
"color" $color
"title" $title
"href" $href
"content" $content
"thumbnail" $thumbnail
) -}}
{{- end -}}

View File

@@ -1,52 +1,31 @@
<!--
Displays a release button that links to a specific release. Use the optional state to indicate if it is a new or
deprecated feature.
"version": Required version string, expects semver notation with a "v" prefix.
"state": Optional state, either "new" or "deprecated".
"short": Optional flag to indicate the release button should use short notation.
"size" Optional size of the button, either "sm", "md" (default), or "lg".
"class": Optional class attribute of the button element.
"inline": If set, renders the release button inline (defaults to false).
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $error := false -}}
{{ $error := false }}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "release" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{- $version := .Get "version" | default "" -}}
{{- $inline := false -}}
{{- $state := .Get "state" | default "new" -}}
{{- $supportedStates := slice "new" "deprecated" -}}
{{- if not (in $supportedStates $state) -}}
{{- errorf "Invalid value for param 'state': %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{- $shortParam := "false" -}}
{{- $short := false -}}
{{- with .Get "short" }}{{ $shortParam = . }}{{ end -}}
{{- $supportedFlags := slice "true" "false" -}}
{{- if in $supportedFlags $shortParam -}}
{{- if eq $shortParam "true" }}{{ $short = true }}{{ end -}}
{{- else -}}
{{- errorf "Invalid value for param 'short': %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{- $inlineParam := "false" -}}
{{ with .Get "short" }}{{ $short = partial "utilities/CastBool.html" . }}{{ end -}}
{{- $inline := false -}}
{{- with .Get "inline" }}{{ $inlineParam = . }}{{ end -}}
{{- $supportedFlags := slice "true" "false" -}}
{{- if in $supportedFlags $inlineParam -}}
{{- if eq $inlineParam "true" }}{{ $inline = true }}{{ end -}}
{{- else -}}
{{- errorf "Invalid value for param 'inline': %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{ with .Get "inline" }}{{ $short = partial "utilities/CastBool.html" . }}{{ end -}}
{{- $title := $version -}}
{{- $color := "primary" -}}
{{- if eq $state "deprecated" -}}
{{- $color = "secondary" -}}
{{- end -}}
{{- $size := .Get "size" | default "md" -}}
{{- $class := .Get "class" | default "" -}}
{{- $icon := "" -}}
{{- $tooltip := "" -}}
@@ -66,7 +45,6 @@
{{- end -}}
{{- end -}}
{{- if not $short -}}
{{- if eq $state "deprecated" -}}
{{- $title = T "deprecatedFeature" $version -}}
@@ -75,16 +53,7 @@
{{- end -}}
{{- end -}}
{{- $size := "md" -}}
{{- with .Get "size" }}{{ $size = . }}{{ end -}}
{{- $supportedSizes := slice "sm" "md" "lg" -}}
{{- if not (in $supportedSizes $size) -}}
{{- errorf "Invalid value for param 'size': %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{- $class := .Get "class" | default "" -}}
<!-- Main code -->
{{- if not $error -}}
{{- if not $inline }}<div class="pb-3">{{ end -}}
{{- partial "assets/button.html" (dict

View File

@@ -1,34 +1,28 @@
<!--
Displays a spinner. The shortcode supports the following arguments:
"color": Optional theme color of the alert, either "primary" (default), "secondary", "success", "danger",
"warning", "info", "light", "dark", "white", or "black".
"grow" Optional flag to indicate the spinner is growing instead of rotating, defaults to false.
"class": Optional class attribute of the spinner wrapping element, e.g. “text-center”.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{ $color := "primary" -}}
{{ with .Get "color" }}{{ $color = . }}{{ end -}}
{{ $supportedColors := slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark" "white" "black" -}}
{{ if not (in $supportedColors $color) -}}
{{ errorf "Invalid value for param 'color': %s" .Position -}}
{{ $color = "primary" -}}
{{ end -}}
{{ $error := false }}
{{ $growParam := "false" -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "spinner" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $color := .Get "color" | default "primary" -}}
{{ $grow := false -}}
{{ with .Get "grow" }}{{ $growParam = . }}{{ end -}}
{{ $supportedFlags := slice "true" "false" -}}
{{ if in $supportedFlags $growParam -}}
{{ if eq $growParam "true" }}{{ $grow = true }}{{ end -}}
{{ else -}}
{{ errorf "Invalid value for param 'grow': %s" .Position -}}
{{ end -}}
{{ with .Get "grow" }}{{ $grow = partial "utilities/CastBool.html" . }}{{ end -}}
{{ $class := .Get "class" | default "" -}}
{{ $class := "" -}}
{{ with .Get "class" }}{{ $class = . }}{{ end -}}
{{ with $class }}<div class="{{ . }}">{{ end }}
<div class="spinner-{{ if $grow }}grow{{ else }}border{{ end }} text-{{ $color }}" role="status">
<span class="visually-hidden">{{ trim .Inner " \r\n" | plainify -}}</span>
</div>
{{ if $class }}</div>{{ end }}
<!-- Main code -->
{{ if not $error }}
{{ with $class }}<div class="{{ . }}">{{ end }}
<div class="spinner-{{ if $grow }}grow{{ else }}border{{ end }} text-{{ $color }}" role="status">
<span class="visually-hidden">{{ trim .Inner " \r\n" | plainify -}}</span>
</div>
{{ if $class }}</div>{{ end }}
{{ end }}

View File

@@ -1,6 +1,14 @@
<!--
Displays text as subscript, provided as unnamed argument.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $error := false -}}
{{- if partial "utilities/IsInvalidArgs.html" (dict "structure" "sub" "args" .Params) -}}
{{- errorf "Invalid arguments: %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{- $text := .Get 0 | default "" -}}

View File

@@ -1,6 +1,14 @@
<!--
Displays text as superscript, provided as unnamed argument.
Copyright © 2023 The Hinode Team / Mark Dumay. All rights reserved.
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
Visit gethinode.com/license for more details.
-->
{{- $error := false -}}
{{- if partial "utilities/IsInvalidArgs.html" (dict "structure" "sup" "args" .Params) -}}
{{- errorf "Invalid arguments: %s" .Position -}}
{{- $error = true -}}
{{- end -}}
{{- $text := .Get 0 | default "" -}}