Skip to content

Commit

Permalink
refactor: support bundle option for twemoji (#520)
Browse files Browse the repository at this point in the history
Signed-off-by: HEIGE-PCloud <heige.pcloud@outlook.com>
  • Loading branch information
HEIGE-PCloud authored Mar 12, 2022
1 parent c2a9cb7 commit e696ecc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@

{{- /* twemoji */ -}}
{{- if $params.twemoji -}}
{{- $source := $cdn.twemojiJS | default "lib/twemoji/twemoji.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- $config = dict "twemoji" true | merge $config -}}
{{- $shims := dict "twemoji" "js/shims/twemoji.js" -}}
{{- $options := dict -}}

{{- if $bundle -}}
{{- else -}}
{{- $source := $cdn.twemojiJS | default "lib/twemoji/twemoji.min.js" -}}
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
{{- $shims := dict "twemoji" "js/shims/twemoji.js" -}}
{{- $options = dict "shims" $shims | merge $options -}}
{{- end -}}

{{- $options = dict "targetPath" "js/twemoji.min.js" | merge $options -}}
{{- $options = dict "minify" true | merge $options -}}
{{- $options = dict "shims" $shims | merge $options -}}
{{- $js := resources.Get "js/lib/twemoji.js" | js.Build $options -}}
{{- $_ := $js.RelPermalink -}}
{{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}
Expand Down

1 comment on commit e696ecc

@vercel
Copy link

@vercel vercel bot commented on e696ecc Mar 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.