Commit Diff


commit - 607de06197074d15a736077d7de3d8e69c1c4317
commit + 207b1f9e829d516ba403094c2230f5494a97349d
blob - 508314ae546982909d9fecfdcab05d9359006336
blob + 23bc65b980d87b0be3cbb92772f352c85a3debbf
--- README.md
+++ README.md
@@ -40,5 +40,11 @@ _merge = 'deep'
 ### head/js
 Подключает js/main.js
 
-## head/pagefind
+### head/pagefind
 Подключение стилей и скрипта, если окружение не является разработкой.
+
+## Shortcodes
+### details
+Корректный details, позволяющий рендерить html.
+
+Аналогично [стандартному](https://gohugo.io/shortcodes/details/#article) shortcode, за исключением способа вызова — необходимо использовать вызов {{% details %}} для рендера внутреннего текста в качестве Markdown.
blob - /dev/null
blob + efea3eae63caac2658d1cac48e2e35f940dbaba6 (mode 644)
--- /dev/null
+++ layouts/_shortcodes/details.html
@@ -0,0 +1,75 @@
+{{- /*
+Renders an HTML details element.
+
+@param {string} [class] The value of the element's class attribute.
+@param {string} [name] The value of the element's name attribute.
+@param {string} [summary] The content of the child summary element.
+@param {string} [title] The value of the element's title attribute.
+@param {bool} [open=false] Whether to initially display the content of the details element.
+
+@reference https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details
+
+@examples
+
+  {{% details %}}
+  A basic collapsible section.
+  {{% /details %}}
+
+  {{% details summary="Custom Summary Text" %}}
+  Showing custom `summary` text.
+  {{% /details %}}
+
+  {{% details summary="Open Details" open=true %}}
+  Contents displayed initially by using `open`.
+  {{% /details %}}
+
+  {{% details summary="Styled Content" class="my-custom-class" %}}
+  Content can be styled with CSS by specifying a `class`.
+
+  Target details element:
+
+  ```css
+  details.my-custom-class { }
+  ```
+
+  Target summary element:
+
+  ```css
+  details.my-custom-class > summary > * { }
+  ```
+
+  Target inner content:
+
+  ```css
+  details.my-custom-class > :not(summary) { }
+  ```
+  {{% /details %}}
+
+  {{% details summary="Grouped Details" name="my-details" %}}
+  Specifying a `name` allows elements to be connected, with only one able to be open at a time.
+  {{% /details %}}
+
+*/}}
+
+{{- /* Get arguments. */}}
+{{- $class := or (.Get "class") "" }}
+{{- $name := or (.Get "name") "" }}
+{{- $summary := or (.Get "summary") "Details" }}
+{{- $title := or (.Get "title") "" }}
+{{- $open := false }}
+{{- if in (slice "false" false 0) (.Get "open") }}
+  {{- $open = false }}
+{{- else if in (slice "true" true 1) (.Get "open") }}
+  {{- $open = true }}
+{{- end }}
+
+{{- /* Render. */}}
+<details
+  {{- with $class }} class="{{ . }}" {{- end }}
+  {{- with $name }} name="{{ . }}" {{- end }}
+  {{- with $open }} open {{- end }}
+  {{- with $title }} title="{{ . }}" {{- end -}}
+>
+  <summary>{{ $summary | .Page.RenderString }}</summary>
+  {{ .Inner -}}
+</details>