Add post: 暗黑能天使
This commit is contained in:
8
layouts/partials/utils/camelize.html
Normal file
8
layouts/partials/utils/camelize.html
Normal file
@@ -0,0 +1,8 @@
|
||||
{{ $input := . }}
|
||||
{{ $regexp := "(-|_)([a-z])" }}
|
||||
{{ $matches := findRE $regexp $input }}
|
||||
{{ range $matches }}
|
||||
{{ $input = $input | replaceRE . (upper .) }}
|
||||
{{ end }}
|
||||
{{ $input = $input | replaceRE "(-|_)" "" }}
|
||||
{{ return $input }}
|
||||
7
layouts/partials/utils/get-bundles.html
Normal file
7
layouts/partials/utils/get-bundles.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{{ $currentPage := . }}
|
||||
{{ $bundles := slice $currentPage }}
|
||||
{{ if and (ne $currentPage.Kind "taxonomy") (or (ne $currentPage $currentPage.FirstSection) (eq $currentPage.Kind "term")) }}
|
||||
{{ $currentBundles := partial "utils/get-bundles" $currentPage.Parent }}
|
||||
{{ $bundles = $bundles | append $currentBundles }}
|
||||
{{ end }}
|
||||
{{ return $bundles }}
|
||||
9
layouts/partials/utils/get-featured.html
Normal file
9
layouts/partials/utils/get-featured.html
Normal file
@@ -0,0 +1,9 @@
|
||||
{{ $video := partial "utils/get-video" (dict "context" . "url" .Params.featuredVideo "keyword" "*featured*") }}
|
||||
{{ $image := partial "utils/get-image" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*") }}
|
||||
{{ $featured := ""}}
|
||||
{{ if $video }}
|
||||
{{ $featured = $video }}
|
||||
{{ else if $image }}
|
||||
{{ $featured = print "<img src=\"" $image "\" class=\"w-full\" alt=\"Featured Image\">" | safeHTML }}
|
||||
{{ end }}
|
||||
{{ return $featured }}
|
||||
56
layouts/partials/utils/get-fontawesome-icons.html
Normal file
56
layouts/partials/utils/get-fontawesome-icons.html
Normal file
@@ -0,0 +1,56 @@
|
||||
{{ $fasIcons := slice }}
|
||||
{{ $fabIcons := slice }}
|
||||
{{ $farIcons := slice }}
|
||||
|
||||
{{/* eureka */}}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-adjust") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-bars") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-calendar") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-caret-down") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-caret-left") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-caret-right") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-clock") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-edit") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-folder") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-globe") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-moon") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-sun") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-th-list") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-user") }}
|
||||
{{ $fasIcons = $fasIcons | append (partial "utils/camelize" "fa-user-circle") }}
|
||||
|
||||
{{/* authors */}}
|
||||
{{ range (.Site.GetPage "taxonomyTerm" "authors").Pages }}
|
||||
{{ range .Params.social }}
|
||||
{{ $icon := partial "utils/camelize" (print "fa-" .icon) }}
|
||||
{{ if and (eq .iconPack "fas") (not (in $fasIcons $icon)) }}
|
||||
{{ $fasIcons = $fasIcons | append $icon }}
|
||||
{{ else if and (eq .iconPack "fab") (not (in $fabIcons $icon)) }}
|
||||
{{ $fabIcons = $fabIcons | append $icon }}
|
||||
{{ else if and (eq .iconPack "far") (not (in $farIcons $icon)) }}
|
||||
{{ $farIcons = $farIcons | append $icon }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* homepage.about */}}
|
||||
{{ $homepage := .Site.GetPage "homepage" }}
|
||||
{{ $widgets := $homepage.Resources }}
|
||||
{{ range $widgets }}
|
||||
{{ if eq .Params.widget.handler "about" }}
|
||||
{{ range .Params.social }}
|
||||
{{ $icon := partial "utils/camelize" (print "fa-" .icon) }}
|
||||
{{ if and (eq .iconPack "fas") (not (in $fasIcons $icon)) }}
|
||||
{{ $fasIcons = $fasIcons | append $icon }}
|
||||
{{ else if and (eq .iconPack "fab") (not (in $fabIcons $icon)) }}
|
||||
{{ $fabIcons = $fabIcons | append $icon }}
|
||||
{{ else if and (eq .iconPack "far") (not (in $farIcons $icon)) }}
|
||||
{{ $farIcons = $farIcons | append $icon }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $icons := dict "fas" $fasIcons "fab" $fabIcons "far" $farIcons }}
|
||||
|
||||
{{ return $icons }}
|
||||
17
layouts/partials/utils/get-image.html
Normal file
17
layouts/partials/utils/get-image.html
Normal file
@@ -0,0 +1,17 @@
|
||||
{{- $img := "" }}
|
||||
{{- $validKeyword := false }}
|
||||
{{- if .keyword }}
|
||||
{{- if (.context.Resources.ByType "image").GetMatch .keyword }}
|
||||
{{- $validKeyword = true}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $validKeyword }}
|
||||
{{- $img = ((.context.Resources.ByType "image").GetMatch .keyword).Permalink }}
|
||||
{{- else if or (hasPrefix .url "//") (or (hasPrefix .url "http://") (hasPrefix .url "https://")) }}
|
||||
{{- $img = (.url | absURL) }}
|
||||
{{- else if resources.GetMatch .url }}
|
||||
{{- $img = (resources.GetMatch .url).Permalink }}
|
||||
{{- else if .url }}
|
||||
{{- $img = (.url | absURL) }}
|
||||
{{- end }}
|
||||
{{- return $img }}
|
||||
13
layouts/partials/utils/get-js-configs.html
Normal file
13
layouts/partials/utils/get-js-configs.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{{- range $key, $value := . }}
|
||||
{{- if or $value (eq $value false) }}
|
||||
{{- $key = partial "utils/camelize" $key }}
|
||||
{{- $key }}:
|
||||
{{- if reflect.IsMap $value }}
|
||||
{
|
||||
{{ partial "utils/get-js-configs" . }}
|
||||
},
|
||||
{{- else -}}
|
||||
"{{ $value }}",
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
18
layouts/partials/utils/get-style-color.html
Normal file
18
layouts/partials/utils/get-style-color.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{{ $style := (index .context.Site.Data.styles (.context.Site.Params.style | default "default")) }}
|
||||
{{ $result := $style.colors }}
|
||||
{{ if $result }}
|
||||
{{ range .path }}
|
||||
{{ if $result }}
|
||||
{{ $result = index $result . }}
|
||||
{{ else }}
|
||||
{{ errorf "Param %s is undefined in style %s" (delimit $.path ".") $.context.Site.Params.style }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if $result }}
|
||||
{{ return $result }}
|
||||
{{ else }}
|
||||
{{ errorf "Param %s is undefined in style %s" (delimit $.path ".") $.context.Site.Params.style }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ errorf "Could not find colors section in style %s." .context.Site.Params.style }}
|
||||
{{ end }}
|
||||
12
layouts/partials/utils/get-style-fonts.html
Normal file
12
layouts/partials/utils/get-style-fonts.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{{ $style := (index .context.Site.Data.styles (.context.Site.Params.style | default "default")) }}
|
||||
{{ $result := slice }}
|
||||
{{ range $style.fonts }}
|
||||
{{ $item := index . $.param }}
|
||||
{{ if $item }}
|
||||
{{ $result = $result | append $item }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{/* TODO: use realtime location */}}
|
||||
{{ errorf "Could not find fonts section in style %s." .context.Site.Params.style }}
|
||||
{{ end }}
|
||||
{{ return $result }}
|
||||
38
layouts/partials/utils/get-summary.html
Normal file
38
layouts/partials/utils/get-summary.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<div class="prose">
|
||||
<a href="{{ .Permalink }}" class="no-underline">
|
||||
<h3 class="mt-0">{{ .LinkTitle }}</h3>
|
||||
</a>
|
||||
{{ if .Description }}
|
||||
{{ .Description | plainify | htmlUnescape }}
|
||||
{{ else if .Summary }}
|
||||
{{ .Summary | plainify | htmlUnescape }}
|
||||
{{ end }}
|
||||
|
||||
{{ if eq .Type "docs" }}
|
||||
<div class="mx-6">
|
||||
{{ range $index, $value := first 3 .Pages }}
|
||||
{{ if gt $index 0 }}
|
||||
<div class="-mx-4 my-4 border-t"></div>
|
||||
{{ end -}}
|
||||
<a href="{{ .Permalink }}" class="no-underline">
|
||||
<h4>{{ .LinkTitle }}</h4>
|
||||
</a>
|
||||
{{ if .Description }}
|
||||
{{ .Description | plainify | htmlUnescape }}
|
||||
{{ else if .Summary }}
|
||||
{{ .Summary | plainify | htmlUnescape }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<a href="{{ .Permalink }}" class="no-underline">
|
||||
<h4>
|
||||
{{ i18n "readMore" }}
|
||||
<i
|
||||
class="fas {{ cond (eq .Site.Language.LanguageDirection "rtl") "fa-caret-left" "fa-caret-right" }} ms-1"
|
||||
></i>
|
||||
</h4>
|
||||
</a>
|
||||
</div>
|
||||
{{ else }}
|
||||
{{ partial "components/post-metadata" . }}
|
||||
{{ end }}
|
||||
</div>
|
||||
7
layouts/partials/utils/get-video.html
Normal file
7
layouts/partials/utils/get-video.html
Normal file
@@ -0,0 +1,7 @@
|
||||
{{ if or (hasPrefix .url "//") (or (hasPrefix .url "http://") (hasPrefix .url "https://")) }}
|
||||
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
|
||||
<iframe src="{{ .url }}" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
{{ else if .url }}
|
||||
<video class="w-full" src="{{ .url | absURL }}" controls></video>
|
||||
{{ end }}
|
||||
1
layouts/partials/utils/hyphenate.html
Normal file
1
layouts/partials/utils/hyphenate.html
Normal file
@@ -0,0 +1 @@
|
||||
{{ return replace . "_" "-" }}
|
||||
4
layouts/partials/utils/standardize-classes.html
Normal file
4
layouts/partials/utils/standardize-classes.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ $classes := replaceRE " +" " " . }}
|
||||
{{ $classes = strings.TrimLeft " " $classes }}
|
||||
{{ $classes = strings.TrimRight " " $classes }}
|
||||
{{ return $classes }}
|
||||
Reference in New Issue
Block a user