mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-25 07:48:54 +00:00
✨ Feat: add echarts support for code blocks
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{{- dict "Options" .Attributes "Inner" .Inner | partial "plugin/echarts.html" -}}
|
||||
@@ -124,7 +124,7 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- /* ECharts */ -}}
|
||||
{{- if .HasShortcode "echarts" -}}
|
||||
{{- if .Store.Get "hasEcharts" -}}
|
||||
{{- $source := $cdn.echartsJS | default "lib/echarts/echarts.min.js" -}}
|
||||
{{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/script.html" -}}
|
||||
{{- $lightTheme := resources.Get "lib/echarts/theme/light.yml" | transform.Unmarshal -}}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{{- /* Echarts support for code fences extended and shortcodes. */ -}}
|
||||
{{- $width := .Options.width | default "100%" -}}
|
||||
{{- $height := .Options.height | default "30rem" -}}
|
||||
{{- $attrs := printf `style="width: %v; height: %v;"` $width $height -}}
|
||||
<div class="echarts" {{ $attrs | safeHTMLAttr }}></div>
|
||||
<template>{{ .Inner | transform.Unmarshal | jsonify }}</template>
|
||||
{{- page.Store.Set "hasEcharts" true -}}
|
||||
@@ -1,7 +1,3 @@
|
||||
{{- $content := .Inner | transform.Unmarshal | jsonify -}}
|
||||
{{- $width := cond .IsNamedParams (.Get "width") (.Get 0) | default "100%" -}}
|
||||
{{- $height := cond .IsNamedParams (.Get "height") (.Get 1) | default "30rem" -}}
|
||||
{{- $attrs := printf `style="width: %v; height: %v;"` $width $height -}}
|
||||
<div class="echarts" {{ $attrs | safeHTMLAttr }}></div>
|
||||
<template>{{ $content }}</template>
|
||||
{{- /* EOF */ -}}
|
||||
{{- $options := .Get "width" | default (.Get 0) | dict "width" -}}
|
||||
{{- $options = .Get "height" | default (.Get 1) | dict "height" | merge $options -}}
|
||||
{{- dict "Options" $options "Inner" .Inner | partial "plugin/echarts.html" -}}
|
||||
|
||||
Reference in New Issue
Block a user