Compare commits

...

3 commits

Author SHA1 Message Date
George Cushen
2b11b7e9fb feat(tailwind): prevent error when using hugo new site
As unfortunately Hugo always triggers error even when using `with` statement with a non-safelisted `os.Getenv` var
2024-06-01 19:27:12 +01:00
George Cushen
6b70757505 feat(tailwind): add include shortcode for re-usable Markdown blocks 2024-06-01 19:21:51 +01:00
George Cushen
776e5c09c0 feat(tailwind): port TOC shortcode 2024-06-01 16:31:32 +01:00
9 changed files with 56 additions and 8 deletions

View file

@ -84,3 +84,8 @@
.backlink {
@apply text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50;
}
/* For ToC shortcode, Spoiler shortcode, and direct HTML Details snippets. */
details > summary {
@apply cursor-pointer font-semibold text-primary-700 dark:text-primary-300;
}

File diff suppressed because one or more lines are too long

View file

@ -80,9 +80,10 @@ module:
security:
funcs:
getenv:
# Allow HUGO_ and HUGO_BLOX_ vars
- ^HUGO_
- ^WC_
- ^HB_
# Allow continuous integration vars
- ^CI$
outputFormats:
backlinks:
mediaType: application/json

View file

@ -1,11 +1,12 @@
{{/* Workaround Hugo concurrency issues (e.g. not detecting Page.Store variables) */}}
{{/* https://discourse.gohugo.io/t/persisting-data-across-the-build-of-a-site/41114/6 */}}
{{/* Use cases: Page.Store use within shortcodes, blox, and backlinks. */}}
{{/* See https://discourse.gohugo.io/t/persisting-data-across-the-build-of-a-site/41114/6 */}}
{{- range $page := site.AllPages }}
{{- $noop := .Content }}
{{ if eq .Type "landing" }}
{{ range $index, $block := .Params.sections }}
{{/* Do not show sections intended only for the demo site. */}}
{{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "WC_DEMO") "true")) }}
{{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "HUGO_BLOX_DEMO") "true")) }}
{{ $block_type := lower ($block.blox | default $block.block) | default "markdown" }}
{{ range $r := site.Data.blox_aliases.renames }}
{{ $block_type = cond (eq $block_type $r.old) $r.new $block_type }}

View file

@ -1,7 +1,7 @@
{{/* Load Hugo Blox */}}
{{ range $index, $block := .Params.sections }}
{{/* Do not show sections intended only for the demo site. */}}
{{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "WC_DEMO") "true")) }}
{{ if or (not $block.demo) ($block.demo | and (eq (os.Getenv "HUGO_BLOX_DEMO") "true")) }}
{{ partial "functions/parse_block_v2" (dict "page" $ "block" $block) }}
{{ end }}
{{ end }}

View file

@ -56,7 +56,7 @@
{{ end }}
{{/* Style */}}
{{ if ne (os.Getenv "WC_POSTCSS") "true" }}
{{ if ne (os.Getenv "HUGO_BLOX_POSTCSS") "true" }}
{{ $styles := resources.Get "dist/wc.min.css" }}
<link href="{{ $styles.RelPermalink }}" rel="stylesheet" />
{{ else }}

View file

@ -0,0 +1,23 @@
{{- /*
Docs: https://docs.hugoblox.com/reference/markdown/#include
Parameters
----------
postional parameter 0 :
Path to the Markdown file to include, relative to the `content` folder.
Example
----------
{{% include "snippet/intro" %}}
*/ -}}
{{- with .Get 0 }}
{{- $page := . -}}
{{- with site.GetPage $page }}
{{- .RenderShortcodes }}
{{- else }}
{{- errorf "The %q shortcode at %s could not locate %q" $.Name $.Position (printf "content/%s.md" .) }}
{{- end }}
{{- else }}
{{- errorf "Call the %q shortcode in %s with the path of the Markdown file to include." .Name .Position }}
{{- end }}

View file

@ -1,5 +1,5 @@
{{/*
Docs: https://docs.hugoblox.com/content/writing-markdown-latex/#toggle-list
Docs: https://docs.hugoblox.com/reference/markdown/#toggle-lists
Parameters
----------

View file

@ -0,0 +1,18 @@
{{/*
Docs: https://docs.hugoblox.com/reference/markdown/#table-of-contents
Parameters
----------
mobile_only : true/false (optional)
Hide TOC on desktop when TOC is shown in right sidebar?
is_open : true/false (optional)
Show the TOC in the open, expanded state?
*/}}
{{ $mobile_only := .Get "mobile_only" | default true }}
{{ $is_open := .Get "is_open" | default false }}
<details class="print:hidden {{with $mobile_only}}xl:hidden{{end}}" {{with $is_open}}open{{end}}>
<summary>{{ i18n "table_of_contents" }}</summary>
<div class="text-sm">
{{ $.Page.TableOfContents }}
</div>
</details>