Add post: 暗黑能天使

This commit is contained in:
2022-05-10 01:13:38 +08:00
parent e0a0b033ae
commit 90b654e708
104 changed files with 3185 additions and 7 deletions

View 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 }}

View 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 }}

View 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 }}

View 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 }}

View 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 }}

View 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 }}

View 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 }}

View 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 }}

View 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>

View 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 }}

View File

@@ -0,0 +1 @@
{{ return replace . "_" "-" }}

View File

@@ -0,0 +1,4 @@
{{ $classes := replaceRE " +" " " . }}
{{ $classes = strings.TrimLeft " " $classes }}
{{ $classes = strings.TrimRight " " $classes }}
{{ return $classes }}