Compare commits

...

26 Commits

Author SHA1 Message Date
Mark Dumay
380ebcd1d8 Merge pull request #686 from gethinode/validation
Fix purge settings and arg init
2023-12-28 17:34:07 +01:00
Mark Dumay
c06499033d Merge branch 'main' into validation 2023-12-28 17:17:49 +01:00
mark
0874957993 Bump package release 2023-12-28 17:16:56 +01:00
mark
6019c7412f Update build stats 2023-12-28 17:16:24 +01:00
mark
30c300cabf Fix bool args init 2023-12-28 17:16:16 +01:00
mark
46f11f02ab Fix default color 2023-12-28 17:03:21 +01:00
mark
71e6029117 Exclude embedded video styles from purging 2023-12-28 15:45:49 +01:00
Mark Dumay
5c67da7882 Merge pull request #685 from gethinode/validation
Fix args validation
2023-12-28 15:16:26 +01:00
Mark Dumay
af4f6de4b9 Merge branch 'main' into validation 2023-12-28 15:05:45 +01:00
mark
9b173d6c68 Bump package version 2023-12-28 15:04:59 +01:00
mark
2f4fb5230d Fix type conversion 2023-12-28 15:04:10 +01:00
mark
9144a1fec3 Fix args 2023-12-28 15:03:48 +01:00
mark
4192af1d46 Fix width arg 2023-12-28 15:02:44 +01:00
mark
0e72124cdc Fix cols arg 2023-12-28 15:02:25 +01:00
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
20 changed files with 83 additions and 73 deletions

View File

@@ -21,6 +21,7 @@ const purgecss = require('@fullhuman/postcss-purgecss')({
'./assets/scss/components/_syntax-dark.scss',
'./assets/scss/components/_syntax-light.scss',
'./assets/scss/components/_table.scss',
'./assets/scss/components/_video.scss',
'./assets/scss/theme/fonts.scss',
'./assets/scss/theme/theme.scss',
'./_vendor/github.com/gethinode/mod-flexsearch/assets/scss/modules/flexsearch/flexsearch.scss',

View File

@@ -39,13 +39,18 @@ arguments:
optional: true
comment: Maximum number of cards to display.
cols:
type: int
type: select
optional: true
default: 3
default: "3"
comment: Number of grid columns.
options:
min: 1
max: 5
values:
- "1"
- "2"
- "3"
- "4"
- "5"
- "auto"
paginate:
type: bool
optional: true

View File

@@ -58,12 +58,12 @@ arguments:
width:
type: select
optional: true
default: 100
default: "100"
comment: Responsive width of the tab group.
options:
values:
- 50
- 100
- "50"
- "100"
group: partial
loading:
type: select

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

@@ -21,6 +21,7 @@ const purgecss = require('@fullhuman/postcss-purgecss')({
'./assets/scss/components/_syntax-dark.scss',
'./assets/scss/components/_syntax-light.scss',
'./assets/scss/components/_table.scss',
'./assets/scss/components/_video.scss',
'./assets/scss/theme/fonts.scss',
'./assets/scss/theme/theme.scss',
'./_vendor/github.com/gethinode/mod-flexsearch/assets/scss/modules/flexsearch/flexsearch.scss',

View File

@@ -19,6 +19,7 @@
"hr",
"html",
"i",
"iframe",
"img",
"input",
"li",
@@ -39,14 +40,8 @@
"sub",
"sup",
"svg",
"table",
"tbody",
"td",
"th",
"thead",
"time",
"title",
"tr",
"ul",
"use"
],
@@ -379,8 +374,6 @@
"syntax-highlight",
"tab-content",
"tab-pane",
"table",
"table-responsive",
"tag-link",
"text-bg-body",
"text-bg-body-tertiary",
@@ -440,7 +433,8 @@
"visually-hidden",
"vr",
"w-100",
"w-50"
"w-50",
"youtube-embedded"
],
"ids": [
"-theme",

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 }}
@@ -26,7 +26,7 @@
{{- $content := .content -}}
{{- $thumbnail := .thumbnail -}}
{{- $color := .color -}}
{{- $color := .color | default "primary" -}}
{{- with $page -}}
{{- if not $title }}{{ $title = .Title }}{{ end -}}

View File

@@ -32,7 +32,7 @@
{{- $layout := "card" -}}
{{- $pane := "none" -}}
{{- $type := "pills" -}}
{{- $vertical := "false" -}}
{{- $vertical := false -}}
{{- $width := 100 -}}
{{- $ratio := "" -}}
{{- $wrap := false -}}
@@ -58,11 +58,11 @@
{{- with index . "layout" }}{{ $layout = . }}{{ end -}}
{{- with index . "pane" }}{{ $pane = . }}{{ end -}}
{{- with index . "type" }}{{ $type = . }}{{ end -}}
{{- with index . "vertical" }}{{ $vertical = . }}{{ end -}}
{{- with index . "vertical" }}{{ $vertical = partial "utilities/CastBool.html" . }}{{ end -}}
{{- with index . "width" }}{{ $width = . }}{{ end -}}
{{- with index . "kind" }}{{ $kind = . }}{{ end -}}
{{- with index . "ratio" }}{{ $ratio = . }}{{ end -}}
{{- with index . "wrap" }}{{ $wrap = . }}{{ end -}}
{{- with index . "wrap" }}{{ $wrap = partial "utilities/CastBool.html" . }}{{ end -}}
{{- end -}}
{{ if isset $page.Params "nested" }}
@@ -148,23 +148,25 @@
<div class="container-xxl {{ $wrapper }}">
{{- partial "assets/section-header.html" $params -}}
{{ warnf "[%s] vertical: %t" $page.Title $vertical}}
{{- $params := (dict
"page" $page
"list" $list
"title" $title
"icon" $icon
"thumbnail" $thumbnail
"ratio" $ratio
"description" $description
"class" $style
"color" $color
"loading" $loading
)
-}}
{{ if eq $layout "card" }}
{{- $partial = "assets/card-group.html" -}}
{{- $params = merge $params (dict
"title" $title
"icon" $icon
"thumbnail" $thumbnail
"ratio" $ratio
"description" $description
"color" $color
"loading" $loading
"max" $max
"cols" $cols
"href" $sectionURL
@@ -180,7 +182,6 @@
{{ else if eq $layout "nav" }}
{{- $partial = "assets/nav.html" -}}
{{- $params = merge $params (dict
"layout" $layout
"id" $section
"pane" $pane
"type" $type
@@ -192,6 +193,13 @@
{{- else -}}
{{- $partial = "assets/list.html" -}}
{{- $params = merge $params (dict
"title" $title
"icon" $icon
"thumbnail" $thumbnail
"ratio" $ratio
"description" $description
"color" $color
"loading" $loading
"layout" $layout
)
-}}

View File

@@ -86,8 +86,9 @@
{{ $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) }}
{{ else if and (in $expected "string") (in (slice "bool" "int" "int64" "float" "float64") $actual) }}
{{ $actual = "string" }}
{{ $val = string $val }}
{{ end }}
{{ if and $val (not (in $expected $actual)) }}

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-beta4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@gethinode/hinode",
"version": "0.22.0-beta",
"version": "0.22.0-beta4",
"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-beta4",
"description": "Hinode is a clean documentation and blog theme for Hugo, an open-source static site generator",
"keywords": [
"hugo",