Skip to content

Commit

Permalink
feat: add support for Alpine JS
Browse files Browse the repository at this point in the history
  • Loading branch information
gcushen committed May 5, 2024
1 parent 3c4070a commit dcdb3d3
Show file tree
Hide file tree
Showing 13 changed files with 2,409 additions and 1,817 deletions.
5 changes: 5 additions & 0 deletions modules/blox-tailwind/assets/dist/lib/alpinejs/cdn.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions modules/blox-tailwind/assets/dist/wc.min.css

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions modules/blox-tailwind/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@
- id: user_profile_latest
translation: Latest

# Countdown widget

- id: days
translation: Days
- id: hours
translation: Hours
- id: minutes
translation: Minutes
- id: seconds
translation: Seconds

# Accomplishments widget

- id: see_certificate
Expand Down
5 changes: 0 additions & 5 deletions modules/blox-tailwind/layouts/partials/blox/hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
{{ with $block.content.text }}<p class="mt-6 text-lg leading-8 text-gray-600 dark:text-gray-300">{{ . | $page.RenderString | emojify }}</p>{{end}}

{{ if $block.content.primary_action.url }}
{{ $pack := or $block.content.primary_action.icon_pack "fas" }}
{{ $pack_prefix := $pack }}
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
{{ $pack_prefix = "fa" }}
{{ end }}
{{ $link := $block.content.primary_action.url }}
{{ $scheme := (urls.Parse $link).Scheme }}
{{ $target := "" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

{{ $logo_url := "" }}
{{ if resources.Get "media/logo.png" | or (resources.Get "media/logo.svg") }}
{{ $logo_url = (partial "functions/get_logo" (dict "constraint" "fit" "size" 192)).Permalink }}
{{/* !CACHED! Can safely cache this site logo variant */}}
{{ $logo_url = (partialCached "functions/get_logo" (dict "constraint" "fit" "size" 192)).Permalink }}
{{ else }}
{{ $logo_url = (partial "functions/get_site_icon" 192).Permalink }}
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,15 @@

{{ $widget_class := printf "blox-%s" (replace (replace $block_type "." "-") "_" "-") }}

{{ $widget_config_file := printf "blocks/%s-config.html" $block_type }}
{{ if templates.Exists (printf "partials/%s" $widget_config_file) }}
{{ $cfg := partial $widget_config_file $widget_args }}
{{ with $cfg.use_container }}{{ $use_container = . }}{{ end }}
{{ with $cfg.inject_section_heading }}{{ $use_cols = . }}{{ end }}
{{end}}
{{/* Now loaded in `init.html` */}}
{{/*
{{ $widget_config_file := printf "blox/%s--CONFIG.html" $block_type }}
{{ if templates.Exists (printf "partials/%s" $widget_config_file) }}
{{ $cfg := partial $widget_config_file $widget_args }}
{{ with $cfg.use_container }}{{ $use_container = . }}{{ end }}
{{ with $cfg.inject_section_heading }}{{ $use_cols = . }}{{ end }}
{{end}}
*/}}

{{/* Dedicated child div for bg prevents parallax 100% height issue within new CSS grid page wrapper. */}}
<section id="{{$hash_id}}" class="relative hbb-section {{$widget_class}} {{if $bg.text_color_light}}dark{{else if (eq $bg.text_color_light false)}}light{{end}} {{with $css_classes}}{{.}}{{end}}" {{with $style}}style="{{. | safeCSS}}"{{end}} {{print $extra_attributes | safeHTMLAttr}}>
Expand Down
20 changes: 19 additions & 1 deletion modules/blox-tailwind/layouts/partials/init.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{{/* 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 */}}
{{- range site.AllPages }}
{{- 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")) }}
{{ $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 }}
{{ end }}
{{ $widget_config_file := printf "blox/%s--CONFIG.html" $block_type }}
{{ if templates.Exists (printf "partials/%s" $widget_config_file) }}
{{/* warnf "Loading blox config at %s" $widget_config_file */}}
{{ $hash_id := $block.id | default (printf "section-%s" (replace $block_type "." "-")) }}
{{ $widget_args := dict "wcPage" $page "wcBlock" $block "wcIdentifier" $hash_id }}
{{ partial $widget_config_file $widget_args }}
{{end}}
{{ end }}
{{ end }}
{{- end -}}
{{- end -}}
7 changes: 7 additions & 0 deletions modules/blox-tailwind/layouts/partials/libraries.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{{/* Load Alpine JS extension? */}}
{{ if (.Page.Store.Get "has_alpine") }}
{{ $alpine_js := resources.Get "dist/lib/alpinejs/cdn.min.js" }}
{{ $alpine_js = $alpine_js | resources.Fingerprint "sha256" }}
<script src="{{ $alpine_js.RelPermalink }}" integrity="{{ $alpine_js.Data.Integrity }}" defer></script>
{{ end }}

{{/* Show site search? */}}
{{ $show_search := site.Params.header.navbar.show_search | default false }}
{{ if $show_search }}
Expand Down
7 changes: 5 additions & 2 deletions modules/blox-tailwind/layouts/partials/site_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
</script>

{{/* Analytics & Verification */}}
{{ partial "blox-analytics/index" . }}
{{/* !CACHED! All analytics and verification code is at site level */}}
{{ partialCached "blox-analytics/index" . }}

{{/* RSS Feed */}}
{{ with .OutputFormats.Get "RSS" }}
Expand Down Expand Up @@ -163,7 +164,8 @@
{{ else if $sharing_image }}
{{ $og_image = $sharing_image.Permalink }}
{{ else if $has_logo }}
{{ $og_image = (partial "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }}
{{/* !CACHED! Can safely cache this site logo variant */}}
{{ $og_image = (partialCached "functions/get_logo" (dict "constraint" "fit" "size" 300)).Permalink }}
{{ $twitter_card = "summary" }}
{{ else }}
{{ $og_image = (partial "functions/get_site_icon" 512).Permalink }}
Expand Down Expand Up @@ -247,6 +249,7 @@
{{ end }}

{{/* Init prior to auto-chunking/bundling scripts due to Hugo concurrency issues */}}
{{/* !CACHED! Initialized once at site level and then cached for each page */}}
{{- partialCached "init.html" . -}}

{{/* Load Third-Party Libraries */}}
Expand Down
1 change: 1 addition & 0 deletions modules/blox-tailwind/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"@tailwindcss/nesting": "0.0.0-insiders.565cd3e",
"alpinejs": "^3.13.10",
"dotenv": "^16.3.1",
"katex": "^0.16.9",
"markmap-autoloader": "^0.15.4",
Expand Down

0 comments on commit dcdb3d3

Please sign in to comment.