feat(search): add more params for search and improve search index (#279)

This commit is contained in:
Dillon
2020-04-29 02:34:28 +08:00
committed by GitHub
parent aa5f490aae
commit 16a4e94117
19 changed files with 169 additions and 81 deletions

View File

@@ -3,4 +3,4 @@
{{- $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>
{{- dict "echarts" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}
{{- .Page.Scratch.SetInMap "this" "echarts" true -}}

View File

@@ -30,4 +30,4 @@
{{- $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" .Page.Scratch) -}}
<div class="mapbox" id="{{ $id }}" style="width: {{ $width }}; height: {{ $height }};"></div>
{{- dict "mapbox" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}
{{- .Page.Scratch.SetInMap "this" "mapbox" true -}}

View File

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

View File

@@ -39,4 +39,4 @@
{{- else -}}
<meting-js server="{{ .Get 0 }}" type="{{ .Get 1 }}" id="{{ .Get 2 }}" theme="{{ $theme }}"></meting-js>
{{- end -}}
{{- dict "music" true | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}
{{- .Page.Scratch.SetInMap "this" "music" true -}}

View File

@@ -1,8 +1,10 @@
{{- $content := .Inner | .Page.RenderString -}}
{{- $id := partial "function/id.html" (dict "content" $content) -}}
{{- $tag := .Get 1 | default "div" -}}
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}
{{- $style := .Get 0 | printf "#%s{%s}" $id -}}
{{- $res := resources.FromString (printf "temp/%s.scss" $id) $style -}}
{{- $res = $res | toCSS (dict "targetPath" (printf "temp/%s.css" $id)) -}}
{{- printf `<%s id="%s">%s</%s>` $tag $id $content $tag | safeHTML -}}
<style>{{ $res.Content | safeCSS }}</style>
{{- $styleArr := (.Page.Scratch.Get "this").styleArr | default slice -}}
{{- $styleArr | append $res.Content | .Page.Scratch.SetInMap "this" "styleArr" -}}

View File

@@ -22,9 +22,10 @@
{{- $content = trim $content "\n" -}}
{{- $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 -}}
{{- $typeitMap := (.Page.Scratch.Get "this").typeitMap | default dict -}}
{{- $group := index $typeitMap $key -}}
{{- $group = $group | default slice | append $id -}}
{{- dict $key $group | dict "typeitMap" | merge (.Page.Scratch.Get "this") | .Page.Scratch.Set "this" -}}
{{- dict $key $group | merge $typeitMap | .Page.Scratch.SetInMap "this" "typeitMap" -}}
<div class="typeit">
{{- printf `<%s id="%s" class="%s"></%s>` $tag $id (delimit $classList " ") $tag | safeHTML -}}