mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-13 06:14:48 +00:00
feat: migrate more blocks to v2 block system
This commit is contained in:
1 parent
7a3d11a2a5
commit
41418661b6
4 files changed
+308
No files matched your search
@@ -0,0 +1,64 @@
|
||||
{{/* Wowchemy Blocks: Accomplishments */}}
|
||||
{{/* Documentation: https://wowchemy.com/blocks/ */}}
|
||||
{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}}
|
||||
|
||||
{{/* Initialise */}}
|
||||
{{ $page := .wcPage }}
|
||||
{{ $block := .wcBlock }}
|
||||
{{ $columns := $block.design.columns | default "1" }}
|
||||
|
||||
<!-- Accomplishments widget -->
|
||||
<div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
|
||||
{{ with $block.Content }}{{ . }}{{ end }}
|
||||
|
||||
{{ if $block.content.items }}
|
||||
{{ range $idx, $key := sort $block.content.items ".date_start" "desc" }}
|
||||
<div class="card experience course">
|
||||
<div class="card-body">
|
||||
{{- $svg_icon := resources.Get (printf "media/icons/brands/%s.svg" (replace (lower .organization) " " "_")) -}}
|
||||
{{- if $svg_icon }}
|
||||
<div class="d-flex align-content-start">
|
||||
<div class="mr-2 mb-2">
|
||||
{{- with .organization_url}}<a href="{{.}}" target="_blank" rel="noopener">{{end -}}
|
||||
<img src="{{ $svg_icon.RelPermalink }}" width="56px" height="56px" alt="{{.organization | plainify}}" loading="lazy">
|
||||
{{- with .organization_url}}</a>{{end -}}
|
||||
</div>
|
||||
<div>
|
||||
{{ end }}
|
||||
|
||||
{{- with .url -}}<a href="{{.}}" target="_blank" rel="noopener">{{- end -}}
|
||||
<div class="section-subheading card-title exp-title text-muted my-0">{{.title | markdownify | emojify}}</div>
|
||||
{{- with .url -}}</a>{{- end -}}
|
||||
|
||||
<div class="card-subtitle my-0 article-metadata">
|
||||
{{- with .organization_url}}<a href="{{.}}" target="_blank" rel="noopener">{{end -}}
|
||||
{{- .organization | markdownify | emojify -}}
|
||||
{{- with .organization_url}}</a>{{end -}}
|
||||
|
||||
<span class="middot-divider"></span>
|
||||
|
||||
{{ (time .date_start) | time.Format ($block.content.date_format | default "Jan 2006") }}
|
||||
{{ if .date_end}}
|
||||
– {{ (time .date_end) | time.Format ($block.content.date_format | default "Jan 2006") }}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{- if $svg_icon}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{with .description}}
|
||||
<div class="card-text">{{. | markdownify | emojify}}</div>
|
||||
{{end}}
|
||||
|
||||
{{ with .certificate_url }}
|
||||
<a class="card-link" href="{{.}}" target="_blank" rel="noopener">
|
||||
{{ i18n "see_certificate" | default "See certificate" }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -0,0 +1,46 @@
|
||||
{{/* Wowchemy Blocks: Features */}}
|
||||
{{/* Documentation: https://wowchemy.com/blocks/ */}}
|
||||
{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}}
|
||||
|
||||
{{/* Initialise */}}
|
||||
{{ $page := .wcPage }}
|
||||
{{ $block := .wcBlock }}
|
||||
|
||||
<div class="row featurette">
|
||||
{{ with $block.content.title }}
|
||||
<div class="col-md-12 section-heading">
|
||||
<h1>{{ . | markdownify | emojify }}</h1>
|
||||
{{ if $block.content.subtitle }}<p>{{ $block.content.subtitle | markdownify | emojify }}</p>{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ with $block.content.text }}
|
||||
<div class="col-md-12">
|
||||
{{ . | emojify | markdownify }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
{{ range $block.content.items }}
|
||||
{{ $pack := or .icon_pack "fas" }}
|
||||
{{ $pack_prefix := $pack }}
|
||||
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
|
||||
{{ $pack_prefix = "fa" }}
|
||||
{{ end }}
|
||||
<div class="col-12 col-sm-4">
|
||||
{{ with .icon }}
|
||||
<div class="featurette-icon">
|
||||
{{- if eq $pack "emoji" -}}
|
||||
{{- . | emojify -}}
|
||||
{{- else if eq $pack "custom" -}}
|
||||
{{- $svg_icon := resources.Get (printf "media/icons/%s.svg" .) -}}
|
||||
{{- if $svg_icon -}}<img src="{{ $svg_icon.RelPermalink }}" alt="{{.}}" class="svg-icon svg-baseline" loading="lazy">{{- end -}}
|
||||
{{- else -}}
|
||||
<i class="{{ $pack }} {{ $pack_prefix }}-{{ . }}"></i>
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{ end }}
|
||||
<div class="section-subheading">{{ .name | markdownify | emojify }}</div>
|
||||
{{ with .description }}<p>{{ . | markdownify | emojify }}</p>{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
@@ -0,0 +1,92 @@
|
||||
{{/* Wowchemy Blocks: Hero */}}
|
||||
{{/* Documentation: https://wowchemy.com/blocks/ */}}
|
||||
{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}}
|
||||
|
||||
{{/* Initialise */}}
|
||||
{{ $page := .wcPage }}
|
||||
{{ $block := .wcBlock }}
|
||||
{{ $bg := $block.design.background }}
|
||||
|
||||
{{ if $block.content.image.filename }}
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6 text-center text-md-left">
|
||||
{{ end }}
|
||||
|
||||
{{ with $block.content.title }}
|
||||
<h1 class="hero-title">{{ . | markdownify }}</h1>
|
||||
{{ end }}
|
||||
|
||||
{{ with $block.content.text }}
|
||||
<div class="hero-lead">{{ . | markdownify | emojify }}</div>
|
||||
{{ end }}
|
||||
|
||||
{{/* Call-to-action link */}}
|
||||
{{ if $block.content.cta.url }}
|
||||
{{ $pack := or $block.content.cta.icon_pack "fas" }}
|
||||
{{ $pack_prefix := $pack }}
|
||||
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
|
||||
{{ $pack_prefix = "fa" }}
|
||||
{{ end }}
|
||||
{{ $link := $block.content.cta.url }}
|
||||
{{ $scheme := (urls.Parse $link).Scheme }}
|
||||
{{ $target := "" }}
|
||||
{{ if not $scheme }}
|
||||
{{ $link = $link | relLangURL }}
|
||||
{{ else if in (slice "http" "https") $scheme }}
|
||||
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
|
||||
{{ end }}
|
||||
<p class="cta-btns">
|
||||
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }} class="btn {{if $bg.text_color_light}}btn-light{{else}}btn-primary{{end}} btn-lg mb-md-1">{{ if $block.content.cta.icon }}<i class="{{ $pack }} {{ $pack_prefix }}-{{ $block.content.cta.icon }} pr-1" aria-hidden="true"></i>{{end}}{{ $block.content.cta.label | markdownify | emojify | safeHTML }}</a>
|
||||
|
||||
{{/* Alternative Call-to-action link */}}
|
||||
{{ if $block.content.cta_alt.url }}
|
||||
{{ $link := $block.content.cta_alt.url }}
|
||||
{{ $scheme := (urls.Parse $link).Scheme }}
|
||||
{{ $target := "" }}
|
||||
{{ if not $scheme }}
|
||||
{{ $link = $link | relLangURL }}
|
||||
{{ else if in (slice "http" "https") $scheme }}
|
||||
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
|
||||
{{ end }}
|
||||
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }} class="hero-cta-alt btn-lg pl-md-4">{{ $block.content.cta_alt.label | markdownify | emojify | safeHTML }} <i class="fas fa-angle-right"></i></a>
|
||||
{{ end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
{{/* Call-to-action note */}}
|
||||
{{ with $block.content.cta_note }}
|
||||
<p class="hero-note text-muted mb-3 mb-md-1">
|
||||
{{ .label | markdownify | emojify | safeHTML }}
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
{{/* Hero image */}}
|
||||
{{ if $block.content.image.filename }}
|
||||
</div>
|
||||
<div class="col-12 mx-auto col-md-6 {{if $block.content.design.flip}}order-md-first{{end}} hero-media">
|
||||
{{- $image := resources.Get (path.Join "media" $block.content.image.filename) -}}
|
||||
{{ if $image }}
|
||||
{{ $isSVG := eq $image.MediaType.SubType "svg" }}
|
||||
{{ if $isSVG -}}
|
||||
<img src="{{ $image.RelPermalink }}" alt="{{ $block.Title }}">
|
||||
{{- else }}
|
||||
{{ $legacy_img := $image.Resize "400x" }}
|
||||
{{ $img_src := "" }}
|
||||
{{ $img_src_set := slice }}
|
||||
{{ $widths := slice 1200 800 400 }}
|
||||
|
||||
{{ range $widths }}
|
||||
{{ $src_link := ($image.Resize (printf "%dx" .)).RelPermalink }}
|
||||
{{ if eq $img_src "" }}
|
||||
{{ $img_src = $src_link }}
|
||||
{{ end }}
|
||||
{{ $img_src_set = $img_src_set | append (printf "%s %dw" $src_link .) }}
|
||||
{{ end }}
|
||||
{{ $img_src_set = delimit $img_src_set "," }}
|
||||
|
||||
<img src="{{ $legacy_img.RelPermalink }}" srcset="{{ $img_src_set }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ $block.Title }}">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
@@ -0,0 +1,106 @@
|
||||
{{/* Wowchemy Blocks: Portfolio */}}
|
||||
{{/* Documentation: https://wowchemy.com/blocks/ */}}
|
||||
{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}}
|
||||
|
||||
{{/* Initialise */}}
|
||||
{{ $page := .wcPage }}
|
||||
{{ $block := .wcBlock }}
|
||||
{{ $columns := $block.design.columns | default "1" }}
|
||||
{{ $view := $block.design.view | default "masonry" }}
|
||||
|
||||
{{/* Require Isotope */}}
|
||||
{{ $page.Page.Store.Set "has_isotope" true }}
|
||||
|
||||
<div class="col-12 {{if eq $columns "2"}}col-lg-8{{end}}">
|
||||
|
||||
{{ with $block.content.text }}{{ . | markdownify }}{{ end }}
|
||||
|
||||
{{ if $block.content.buttons }}
|
||||
|
||||
{{ $filter_default := default (int $block.content.default_button_index) 0 }}
|
||||
|
||||
{{/* Parse default filter tag from front matter in the form of either tag name or CSS class name. */}}
|
||||
{{ $default_filter_item := (index $block.content.buttons ($filter_default)) }}
|
||||
{{ $default_data_filter := "" }}
|
||||
{{ with $default_filter_item.filter }}
|
||||
{{ $default_data_filter = . }}
|
||||
{{ else }}
|
||||
{{ $default_filter_tag := $default_filter_item.tag }}
|
||||
{{ if or (eq (substr $default_filter_tag 0 1) "*") (eq (substr $default_filter_tag 0 1) ".") }}
|
||||
{{ $default_data_filter = $default_filter_tag }}
|
||||
{{ else }}
|
||||
{{ $default_data_filter = printf ".js-id-%s" (lower (replace $default_filter_tag " " "-")) }}
|
||||
{{ end }}
|
||||
{{end}}
|
||||
|
||||
<span class="d-none default-project-filter">{{ $default_data_filter }}</span>
|
||||
|
||||
{{/* Only show filter buttons if there are multiple filters. */}}
|
||||
{{ if gt (len $block.content.buttons) 1 }}
|
||||
<div class="project-toolbar">
|
||||
<div class="project-filters">
|
||||
<div class="btn-toolbar {{if eq $columns "1"}}d-flex justify-content-center{{end}}">
|
||||
<div class="btn-group flex-wrap">
|
||||
{{ range $idx, $item := $block.content.buttons }}
|
||||
{{/* Parse filter tag from front matter in the form of either tag name or CSS class name. */}}
|
||||
{{ $data_filter := "" }}
|
||||
{{ with .filter }}
|
||||
{{ $data_filter = . }}
|
||||
{{ else }}
|
||||
{{ if or (eq (substr .tag 0 1) "*") (eq (substr .tag 0 1) ".") }}
|
||||
{{ $data_filter = .tag }}
|
||||
{{ else }}
|
||||
{{ $data_filter = printf ".js-id-%s" (lower (replace .tag " " "-")) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<a href="#" data-filter="{{ $data_filter | safeHTMLAttr }}" class="btn btn-primary btn-lg{{ if eq $idx $filter_default }} active{{ end }}">{{ .name }}</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<div class="{{ if or $block.content.buttons (in (slice "masonry" 3) $view) }}isotope projects-container{{end}} {{if in (slice "masonry" 3) $view}}js-layout-masonry{{else}}row js-layout-row{{end}} {{ if eq $view "showcase" }}project-showcase{{end}}">
|
||||
|
||||
{{/* Query */}}
|
||||
{{ $query := site.Pages }}
|
||||
|
||||
{{/* Filters */}}
|
||||
{{ with $block.content.page_type }}
|
||||
{{/* Legacy filter, superseded by `filters.folders` */}}
|
||||
{{ $query = where $query "Type" . }}
|
||||
{{ end }}
|
||||
{{ with $block.content.filters.folders }}
|
||||
{{ $query = where $query "Section" "in" . }}
|
||||
{{ end }}
|
||||
{{ with $block.content.filters.tags }}
|
||||
{{ $query = where $query "Params.tags" "intersect" . }}
|
||||
{{ end }}
|
||||
{{ with $block.content.filters.exclude_tags }}
|
||||
{{ $query = $query | symdiff (where site.Pages "Params.tags" "intersect" .) }}
|
||||
{{ end }}
|
||||
{{ with ($block.content.filters.kinds | default (slice "page")) }}
|
||||
{{ $query = where $query "Kind" "in" . }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Sort */}}
|
||||
{{ $sort_by := $block.content.sort_by | default "Date" }}
|
||||
{{ $sort_ascending := $block.content.sort_ascending | default (eq $block.content.order "asc") | default false }}
|
||||
{{ $sort_order := cond $sort_ascending "asc" "desc" }}
|
||||
{{ $query = sort $query $sort_by $sort_order }}
|
||||
|
||||
{{ range $index, $item := $query }}
|
||||
{{ $js_tag_classes := delimit (apply (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") "lower" ".") " " }}
|
||||
{{ if in (slice "masonry" 3) $view }}
|
||||
<div class="project-card project-item isotope-item {{ $js_tag_classes | safeHTMLAttr }}">
|
||||
{{else}}
|
||||
<div class="col-12 isotope-item {{ $js_tag_classes | safeHTMLAttr }}">
|
||||
{{end}}
|
||||
{{ partial "functions/render_view" (dict "page" $block "item" . "view" $view "index" $index) }}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user