Compare commits

...

12 Commits

Author SHA1 Message Date
Mark Dumay
8300b9afee Merge pull request #684 from gethinode/validation
Fix args validation
2023-12-28 14:46:59 +01:00
Mark Dumay
5f61e74dfb Merge branch 'main' into validation 2023-12-28 14:40:46 +01:00
mark
44b3ccd21e Bump package release 2023-12-28 14:39:44 +01:00
mark
29e54ce7ec Fix accordion rendering 2023-12-28 14:38:58 +01:00
mark
f2835209c6 Fix rendering 2023-12-28 14:38:47 +01:00
mark
a0a1b8a9c0 Refactor table shortcode 2023-12-28 14:37:38 +01:00
mark
83f6ec1cb9 Fix persona args 2023-12-28 13:33:17 +01:00
mark
af5b07202e Fix image args 2023-12-28 13:25:27 +01:00
mark
0bcfa59a12 Fix error message 2023-12-28 13:25:03 +01:00
mark
e00095f68d Improve navbar validation error message 2023-12-28 07:38:29 +01:00
mark
5cbd2a1a82 Fix validation error message 2023-12-28 07:28:42 +01:00
mark
9b5a45a3f6 Fix kb args validation 2023-12-28 07:16:18 +01:00
13 changed files with 44 additions and 44 deletions

View File

@@ -20,6 +20,10 @@ arguments:
- lg
- xl
- xxl
class:
type: string
optional: true
comment: Class attribute of the table element, e.g. “table-striped-columns w-auto”.
body:
type: string
optional: false

View File

@@ -6,7 +6,7 @@
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "card-group" "child" "card" "args" .) }}
{{- errorf "partial [assets/card.html] - Invalid arguments" -}}
{{- errorf "partial [assets/card-group.html] - Invalid arguments" -}}
{{ end }}
<!-- Initialize arguments and default values -->

View File

@@ -30,7 +30,7 @@
{{- $mode := .mode -}}
{{- $title := .title -}}
{{- $loading := .loading -}}
{{- partial "assets/image.html" (dict "url" $thumbnail "title" $title "outerClass" $style "mode" $mode "loading" $loading) -}}
{{- partial "assets/image.html" (dict "url" $thumbnail "title" $title "wrapper" $style "mode" $mode "loading" $loading) -}}
{{- end -}}
{{- $page := .page -}}

View File

@@ -8,7 +8,7 @@
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "nav" "args" . "group" "partial") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ errorf "partial [assets/nav.html] - Invalid arguments" -}}
{{ $error = true }}
{{ end }}
@@ -75,7 +75,6 @@
"color" $color
"content" (partial "utilities/GetDescription.html" $item)
"thumbnail" $thumbnail
"loading" $loading
) -}}
{{- else -}}
{{ $illustration := (partial "utilities/GetIllustration.html" (dict "item" $item)) }}

View File

@@ -8,7 +8,7 @@
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "navbar" "args" . "group" "partial") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ errorf "partial [assets/navbar.html] - Invalid arguments" -}}
{{ $error = true }}
{{ end }}

View File

@@ -8,7 +8,7 @@
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "persona" "args" . "group" "partial") }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ errorf "partial [assets/persona.html] - Invalid arguments" -}}
{{ $error = true }}
{{ end }}

View File

@@ -22,10 +22,10 @@
{{- $body := .Inner -}}
{{- if $open -}}
{{- $pattern := printf "data-bs-parent=\"#%s\"" $id -}}
{{- $body = (replace .Inner $pattern "") | .Page.RenderString | safeHTML }}
{{- $body = (replace .Inner $pattern "") }}
{{- end -}}
<div id="{{ $id }}" class="accordion mb-3{{ with $class }} {{ . }}{{ end }}">
{{- $body -}}
{{- $body | safeHTML -}}
</div>
{{ end }}

View File

@@ -31,18 +31,20 @@
{{- if eq $lang "hugo" }}{{ $lang = "markdown" }}{{ end -}}
<!-- Main code -->
<div class="rounded border mb-3">
{{- if eq $show_preview true -}}
<div {{ with $id }}id="{{ . }}"{{ end }} class="rounded-top p-3 {{ with $class }} {{ . }}{{ end }}">
{{- $content | .Page.RenderString -}}
</div>
{{- end -}}
{{- if eq $show_markup true -}}
<div class="d-flex align-items-center ps-3 pe-3 py-1{{ if $show_preview }} border-top{{ else }} rounded-top{{ end }} border-bottom syntax-highlight">
<small class="font-monospace text-body text-uppercase">{{- $lang -}}</small>
</div>
<div class="rounded-bottom syntax-highlight border-none">
{{- highlight (trim $content "\r\n") $lang "" -}}
</div>
{{- end -}}
</div>
{{ if not $error }}
<div class="rounded border mb-3">
{{- if eq $show_preview true -}}
<div {{ with $id }}id="{{ . }}"{{ end }} class="rounded-top p-3 {{ with $class }} {{ . }}{{ end }}">
{{- $content | .Page.RenderString | safeHTML -}}
</div>
{{- end -}}
{{- if eq $show_markup true -}}
<div class="d-flex align-items-center ps-3 pe-3 py-1{{ if $show_preview }} border-top{{ else }} rounded-top{{ end }} border-bottom syntax-highlight">
<small class="font-monospace text-body text-uppercase">{{- $lang -}}</small>
</div>
<div class="rounded-bottom syntax-highlight border-none">
{{- highlight (trim $content "\r\n") $lang "" | safeHTML -}}
</div>
{{- end -}}
</div>
{{ end }}

View File

@@ -7,7 +7,7 @@
{{ $error := false -}}
<!-- Validate arguments -->
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "link" "args" .Params ) }}
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "kbd" "args" .Params ) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}

View File

@@ -17,7 +17,7 @@
{{ $path := .Get "path" }}
{{ $page := "" }}
{{ if $path }}{{ $page = .Site.GetPage $path }}{{ end }}
{{ if not $page }}
{{ if and $path (not $page) }}
{{ errorf "Cannot find page '%s': %s" $path .Position -}}
{{ $error = true -}}
{{ end }}

View File

@@ -13,30 +13,25 @@
{{ end }}
<!-- Initialize arguments -->
{{- $responsiveVals := slice "none" "sm" "md" "lg" "xl" "xxl" -}}
{{- $responsive := intersect .Params $responsiveVals -}}
{{- $main := complement $responsive .Params -}}
{{- if in $responsive "none" -}}
{{- $responsive = slice -}}
{{- else if not $responsive -}}
{{ $responsive = slice -}}
{{- end -}}
{{ $breakpoint := "" }}
{{ $class := "" }}
{{- if .IsNamedParams -}}
{{ $breakpoint = .Get "breakpoint" }}
{{ $class = .Get "class" | default "" }}
{{ else }}
{{ $breakpoint = .Get 0 }}
{{ end }}
{{ if eq $breakpoint "none" }}{{ $breakpoint = "" }}{{ end }}
<!-- Main code -->
{{- $input := .Inner | .Page.RenderString }}
{{- $input = replace $input "style=\"text-align:left\"" "class=\"text-start\"" -}}
{{- $input = replace $input "style=\"text-align:center\"" "class=\"text-center\"" -}}
{{- $input = replace $input "style=\"text-align:right\"" "class=\"text-end\"" -}}
{{- $class := delimit $main " " -}}
{{- $old := "<table>" -}}
{{- $new := printf "<table class=\"table %s\">" $class -}}
{{ $input := replace $input $old $new -}}
{{ $attr := "" }}
{{ range $responsive }}
{{ $attr = printf "%s table-responsive-%s" $attr . }}
{{ end }}
{{- if $responsive }}<div class="table-responsive {{ trim $attr " " }}">{{ end -}}
<div class="{{- with $breakpoint }}table-responsive table-responsive-{{ . }}{{ end -}}">
{{ $input | safeHTML }}
{{- if $responsive }}</div>{{ end -}}
</div>

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@gethinode/hinode",
"version": "0.22.0-beta",
"version": "0.22.0-beta2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@gethinode/hinode",
"version": "0.22.0-beta",
"version": "0.22.0-beta2",
"license": "MIT",
"devDependencies": {
"@fullhuman/postcss-purgecss": "^5.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "@gethinode/hinode",
"version": "0.22.0-beta",
"version": "0.22.0-beta2",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [
"hugo",