Browse Source

refactor(shortcodes): separate from hackcss components

Josh Habdas 1 year ago
parent
commit
0c7191e06f
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74

layouts/partials/components/facets/textattrs.html → layouts/partials/components/common/textattrs.html View File


+ 1
- 1
layouts/partials/components/form.html View File

@@ -8,5 +8,5 @@
8 8
   {{ if in (slice "on" "off") .autocomplete }}autocomplete="{{ .autocomplete }}" {{ end }}
9 9
   {{ if in (slice "get" "post") .method }}method="{{ .method }}" {{ end }}
10 10
   class="form{{ with .class }} {{ . }}{{ end }}">
11
-  {{ .body }}
11
+  {{- .body -}}
12 12
 </form>

+ 0
- 6
layouts/partials/components/navmenu.html View File

@@ -1,6 +0,0 @@
1
-<nav itemscope itemtype="http://schema.org/SiteNavigationElement">
2
-  {{ range (index .menus .name) }}
3
-    {{ $is_active := or ($.page.IsMenuCurrent $.name .) ($.page.HasMenuCurrent $.name .) }}
4
-    <a itemprop="url" {{ if $is_active }}class="active"{{ end }} href="{{ .URL }}"><span itemprop="name">{{ .Name }}</span></a>
5
-  {{- end }}
6
-</nav>

+ 1
- 1
layouts/partials/components/textarea.html View File

@@ -1,6 +1,6 @@
1 1
 {{ $permitted_attrs := .permitted_attrs | default (slice "id" "name" "class" "autocomplete" "autofocus" "cols" "disabled" "form" "maxlength" "minlength" "name" "placeholder" "readonly" "required" "rows" "spellcheck" "wrap" "tabindex") }}
2 2
 {{ $boolean_attrs := .boolean_attrs | default (slice "autofocus" "disabled" "readonly" "required") }}
3 3
 {{ $validations := .validations | default (dict "spellcheck" (slice "true" "default" "false") "autocomplete" (slice "on" "off") "wrap" (slice "hard" "soft" "off")) }}
4
-<textarea {{ partial "components/facets/textattrs.html" (dict "attrs" .attrs "permitted_attrs" $permitted_attrs "boolean_attrs" $boolean_attrs "validations" $validations) | safeHTMLAttr }}>
4
+<textarea {{ partial "components/common/textattrs.html" (dict "attrs" .attrs "permitted_attrs" $permitted_attrs "boolean_attrs" $boolean_attrs "validations" $validations) | safeHTMLAttr }}>
5 5
   {{- with .body }}{{ . }}{{ end -}}
6 6
 </textarea>

+ 1
- 1
layouts/partials/components/textinput.html View File

@@ -1,4 +1,4 @@
1 1
 {{ $permitted_attrs := .permitted_attrs | default (slice "id" "name" "class" "autocomplete" "autofocus" "disabled" "form" "formaction" "formmethod" "formnovalidate" "formtarget" "height" "max" "maxlength" "min" "minlength" "multiple" "pattern" "placeholder" "readonly" "required" "size" "spellcheck" "step" "tabindex" "type" "value" "width") }}
2 2
 {{ $boolean_attrs := .boolean_attrs | default (slice "autofocus" "disabled" "readonly" "required") }}
3 3
 {{ $validations := .validations | default (dict "type" (slice "email" "hidden" "number" "password" "search" "tel" "text" "url") "spellcheck" (slice "true" "default" "false") "autocomplete" (slice "off" "on" "name" "honorific-prefix" "given-name" "additional-name" "family-name" "honorific-suffix" "nickname" "email" "username" "new-password" "current-password" "organization-title" "organization" "street-address" "address-line1" "address-line2" "address-line3" "address-level4" "address-level3" "address-level2" "address-level1" "country" "country-name" "postal-code" "cc-name" "cc-given-name" "cc-additional-name" "cc-family-name" "cc-number" "cc-exp" "cc-exp-month" "cc-exp-year" "cc-csc" "cc-type" "transaction-currency" "transaction-amount" "language" "bday" "bday-day" "bday-month" "bday-year" "sex" "tel" "tel-country-code" "tel-national" "tel-area-code" "tel-local" "tel-extension" "email" "impp" "url" "photo")) }}
4
-<input {{ partial "components/facets/textattrs.html" (dict "attrs" .attrs "permitted_attrs" $permitted_attrs "boolean_attrs" $boolean_attrs "validations" $validations)  | safeHTMLAttr }}>
4
+<input {{ partial "components/common/textattrs.html" (dict "attrs" .attrs "permitted_attrs" $permitted_attrs "boolean_attrs" $boolean_attrs "validations" $validations)  | safeHTMLAttr }}>

layouts/partials/components/external.html → layouts/partials/facets/external.html View File


+ 1
- 1
layouts/partials/menu.html View File

@@ -1,3 +1,3 @@
1 1
 {{ if ne .Site.Params.show_menu false }}
2
-  {{ partial "components/navmenu.html" (dict "name" "main" "menus" .Site.Menus "page" .)}}
2
+  {{ partial "facets/navmenu.html" (dict "name" "main" "menus" .Site.Menus "page" .)}}
3 3
 {{ end }}

+ 1
- 1
layouts/partials/powered-by.html View File

@@ -1,6 +1,6 @@
1 1
 {{ if ne .Site.Params.powered_by false }}
2 2
   <p class="muted">
3 3
     This page was generated using
4
-    {{ partial "components/external.html" (dict "itemtype" "significantLink" "body" "After Dark" "href" "https://after-dark.habd.as" "referrerpolicy" "origin-when-cross-origin") }}.
4
+    {{ partial "facets/external.html" (dict "itemtype" "significantLink" "body" "After Dark" "href" "https://after-dark.habd.as" "referrerpolicy" "origin-when-cross-origin") }}.
5 5
   </p>
6 6
 {{ end }}

+ 2
- 2
layouts/shortcodes/external.html View File

@@ -40,9 +40,9 @@ Combined with button shortcode opening in same window with search query:
40 40
 {{ $rel := .Get "rel" }}
41 41
 {{ $itemtype := .Get "itemtype" }}
42 42
 {{ if .IsNamedParams }}
43
-  {{ partial "components/external.html" (dict "href" $href "body" $body "class" $class "referrerpolicy" $referrerpolicy "target" $target "rel" $rel "itemtype" $itemtype "suppress_external" (and .Inner (eq (len (findRE "external" $rel)) 0))) -}}
43
+  {{ partial "facets/external.html" (dict "href" $href "body" $body "class" $class "referrerpolicy" $referrerpolicy "target" $target "rel" $rel "itemtype" $itemtype "suppress_external" (and .Inner (eq (len (findRE "external" $rel)) 0))) -}}
44 44
 {{ else }}
45
-  {{ partial "components/external.html" (dict "href" (.Get 0)) -}}
45
+  {{ partial "facets/external.html" (dict "href" (.Get 0)) -}}
46 46
 {{ end -}}
47 47
 {{- if or (and .IsNamedParams (eq $href nil)) (and (eq .IsNamedParams false) (eq (.Get 0) nil)) }}
48 48
   <p>{{ partial "components/alert.html" (dict "type" "error" "body" (errorf "Invalid use of external shortcode. Please provide an external link.")) }}</p>

+ 0
- 13
layouts/shortcodes/navmenu.html View File

@@ -1,13 +0,0 @@
1
-<!-- {{/*
2
-Attributes: name [default: "main"]
3
-
4
-Display main navigation menu:
5
-{{< navmenu >}}
6
-
7
-Display custom navigation menu:
8
-{{< navmenu "sidebar" >}}
9
-
10
-*/}} -->
11
-
12
-{{ $name := .Get 0 | default "main" }}
13
-{{ partial "components/navmenu.html" (dict "name" $name "menus" .Site.Menus "page" .Page.Page)}}

Loading…
Cancel
Save