feat: improve configuration (#245)

* feat: improve configuration

* fix: fix partials/footer.html error
This commit is contained in:
Dillon
2020-04-21 22:55:06 +08:00
committed by GitHub
parent 8a0e61085c
commit f14301c395
62 changed files with 1548 additions and 1669 deletions

View File

@@ -1,8 +1,6 @@
{{- $scratch := .Page.Scratch.Get "scratch" -}}
{{- $content := .Inner | transform.Unmarshal | jsonify -}}
{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}}
{{- $id := partial "function/id.html" (dict "content" $content "scratch" .Page.Scratch) -}}
{{- $width := cond .IsNamedParams (.Get "width") (.Get 0) | default "100%" -}}
{{- $height := cond .IsNamedParams (.Get "height") (.Get 1) | default "30rem" -}}
<div class="echarts" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
{{- $scratch.Set "echarts" true -}}
{{- dict "echarts" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}

View File

@@ -1,15 +1,15 @@
{{- $scratch := .Page.Scratch.Get "scratch" -}}
{{- $mapbox := (.Page.Scratch.Get "params").page.mapbox | default dict -}}
{{- $lng := cond .IsNamedParams (.Get "lng") (.Get 0) -}}
{{- $lat := cond .IsNamedParams (.Get "lat") (.Get 1) -}}
{{- $zoom := cond .IsNamedParams (.Get "zoom") (.Get 2) | default 10 -}}
{{- $marked := cond .IsNamedParams (.Get "marked") (.Get 3) | ne false -}}
{{- $lightStyle := .Page.Params.mapbox.lightStyle | default .Page.Site.Params.mapbox.lightStyle -}}
{{- $darkStyle := .Page.Params.mapbox.darkStyle | default .Page.Site.Params.mapbox.darkStyle -}}
{{- $navigation := ne .Page.Params.mapbox.navigation false | and (ne .Page.Site.Params.mapbox.navigation false) -}}
{{- $geolocate := ne .Page.Params.mapbox.geolocate false | and (ne .Page.Site.Params.mapbox.geolocate false) -}}
{{- $scale := ne .Page.Params.mapbox.scale false | and (ne .Page.Site.Params.mapbox.scale false) -}}
{{- $fullscreen := ne .Page.Params.mapbox.fullscreen false | and (ne .Page.Site.Params.mapbox.fullscreen false) -}}
{{- $lightStyle := $mapbox.lightStyle -}}
{{- $darkStyle := $mapbox.darkStyle -}}
{{- $navigation := $mapbox.navigation -}}
{{- $geolocate := $mapbox.geolocate -}}
{{- $scale := $mapbox.scale -}}
{{- $fullscreen := $mapbox.fullscreen -}}
{{- $width := "100%" -}}
{{- $height := "20rem" -}}
@@ -28,6 +28,6 @@
{{- end -}}
{{- $darkStyle = $darkStyle | default $lightStyle -}}
{{- $options := dict "lng" $lng "lat" $lat "zoom" $zoom "marked" $marked "lightStyle" $lightStyle "darkStyle" $darkStyle "geolocate" $geolocate "navigation" $navigation "scale" $scale "fullscreen" $fullscreen -}}
{{- $id := partial "function/id.html" (dict "content" $options "scratch" $scratch) -}}
{{- $id := partial "function/id.html" (dict "content" $options "scratch" .Page.Scratch) -}}
<div class="mapbox" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
{{- $scratch.Set "mapbox" true -}}
{{- dict "mapbox" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}

View File

@@ -1,5 +1,3 @@
{{- $scratch := .Page.Scratch.Get "scratch" -}}
{{- $id := partial "function/id.html" (dict "content" (trim .Inner "\n") "scratch" $scratch) -}}
{{- $id := partial "function/id.html" (dict "content" (trim .Inner "\n") "scratch" .Page.Scratch) -}}
<div class="mermaid" id="{{ $id }}"></div>
{{- $scratch.Set "mermaid" true -}}
{{- dict "mermaid" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}

View File

@@ -1,5 +1,3 @@
{{- $scratch := .Page.Scratch.Get "scratch" -}}
{{- $theme := "#448aff" -}}
{{- if .IsNamedParams -}}
{{- $theme = .Get "theme" | default $theme -}}
@@ -41,4 +39,4 @@
{{- else -}}
<meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="{{ $theme }}"></meting-js>
{{- end -}}
{{- $scratch.Set "music" true -}}
{{- dict "music" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}

View File

@@ -1,5 +1,3 @@
{{- $scratch := .Page.Scratch.Get "scratch" -}}
{{- $content := .Inner -}}
{{- $classList := .Get "class" | slice -}}
{{- $tag := .Get "tag" | default "div" -}}
@@ -22,11 +20,11 @@
{{- /* trim the newline */ -}}
{{- $content = trim $content "\n" -}}
{{- $id := partial "function/id.html" (dict "content" $content "scratch" $scratch) -}}
{{- $key := .Get "group" | default $id -}}
{{- $group := index ($scratch.Get "typeitMap" | default dict) $key -}}
{{- $id := partial "function/id.html" (dict "content" $content "scratch" .Page.Scratch) -}}
{{- $key := .Get "group" | string | default $id -}}
{{- $group := index ((.Page.Scratch.Get "this").typeitMap | default dict) $key -}}
{{- $group = $group | default slice | append $id -}}
{{- $scratch.SetInMap "typeitMap" $key $group -}}
{{- dict $key $group | dict "typeitMap" | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}
<div class="typeit">
{{- printf `<%s id="%s" class="%s"></%s>` $tag $id (delimit $classList " ") $tag | safeHTML -}}