-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compatibility): add config for compatibility (Polyfill.io and ob…
…ject-fit-images)
- Loading branch information
Showing
13 changed files
with
108 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{{- .Scratch.Set "version" "0.2.8" -}} | ||
|
||
{{- /* LoveIt theme version detection */ -}} | ||
{{- $VERSION := "0.2.X" -}} | ||
{{- if eq .Site .Sites.First -}} | ||
{{- if not .Site.Params.version -}} | ||
{{- errorf "Configuration Error 配置文件错误\n\nYou haven't configured the LoveIt version param correctly yet. See https://hugoloveit.com/theme-documentation-basics/#basic-configuration\n你还没有正确配置 LoveIt 的版本参数. 参考 https://hugoloveit.com/zh-cn/theme-documentation-basics/#basic-configuration\n" -}} | ||
{{- else if ne .Site.Params.version $VERSION -}} | ||
{{- errorf (printf "Compatibility Error 兼容性错误\n\n%s -> %s:\nYou have an incompatible update. See https://github.com/dillonzq/LoveIt/releases\n你进行了一次不兼容的更新. 参考 https://github.com/dillonzq/LoveIt/releases\n" .Site.Params.version $VERSION) -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- $params := .Params | merge .Site.Params.page -}} | ||
|
||
{{- if eq hugo.Environment "production" -}} | ||
{{- $cdn := .Site.Params.cdn -}} | ||
{{- with $cdn.data -}} | ||
{{- $cdnData := printf "data/cdn/%s" . | resources.Get | transform.Unmarshal -}} | ||
{{- $cdn = dict "simpleIconsPrefix" $cdnData.prefix.simpleIcons -}} | ||
{{- $prefix := $cdnData.prefix.libFiles | default "" -}} | ||
{{- range $key, $value := $cdnData.libFiles -}} | ||
{{- $cdn = printf "%s%s" $prefix $value | dict $key | merge $cdn -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- .Scratch.Set "cdn" $cdn -}} | ||
{{- .Scratch.Set "fingerprint" .Site.Params.fingerprint -}} | ||
{{- .Scratch.Set "analytics" .Site.Params.analytics -}} | ||
{{- .Scratch.Set "comment" $params.comment -}} | ||
{{- if eq .Params.comment true -}} | ||
{{- .Scratch.Set "comment" .Site.Params.comment -}} | ||
{{- else if eq .Params.comment false -}} | ||
{{- .Scratch.Set "comment" dict -}} | ||
{{- end -}} | ||
{{- else if eq .Site .Sites.First -}} | ||
{{- warnf "\n\nCurrent environment is \"development\". The \"comment system\", \"CDN\" and \"fingerprint\" will be disabled.\n当前运行环境是 \"development\". \"评论系统\", \"CDN\" 和 \"fingerprint\" 不会启用.\n" -}} | ||
{{- end -}} | ||
|
||
{{- .Scratch.Set "params" $params -}} | ||
{{- .Scratch.Set "this" dict -}} | ||
|
||
{{- partial "plugin/compatibility.html" . -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{- $compatibility := .Site.Params.compatibility | default dict -}} | ||
{{- $cdn := .Scratch.Get "cdn" | default dict -}} | ||
{{- $fingerprint := .Scratch.Get "fingerprint" -}} | ||
|
||
{{- /* Polyfill.io */ -}} | ||
{{- if $compatibility.polyfill -}} | ||
{{- $features := slice -}} | ||
{{- range resources.Get "data/polyfill.yml" | transform.Unmarshal -}} | ||
{{- range . -}} | ||
{{- $features = $features | append . -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- with $features | uniq -}} | ||
{{- delimit . "%2C" | printf "https://polyfill.io/v3/polyfill.min.js?features=%s" | dict "source" | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{- /* object-fit-images */ -}} | ||
{{- if $compatibility.objectFit -}} | ||
{{- $source := $cdn.objectFitImagesJS | default "lib/object-fit-images/ofi.min.js" -}} | ||
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" .Scratch "data" | partial "scratch/script.html" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters