diff options
author | kdevo <kdevo@users.noreply.github.com> | 2021-12-02 01:50:19 +0300 |
---|---|---|
committer | kdevo <kdevo@users.noreply.github.com> | 2021-12-02 01:50:19 +0300 |
commit | 15782df57560f51c26d529178d4e7d905c978578 (patch) | |
tree | 2ac2d60211dfc8e3c608554ac9ab0b24869999ad | |
parent | 63a4925846c572733f56bf8605901149a710d84e (diff) |
feat(shortcodes/term): refine termynal shortcode
- allow using YAML as inner
instead of putting complicated raw HTML into the content file
-rw-r--r-- | layouts/shortcodes/term.html | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/layouts/shortcodes/term.html b/layouts/shortcodes/term.html index cb24367..818611c 100644 --- a/layouts/shortcodes/term.html +++ b/layouts/shortcodes/term.html @@ -1,3 +1,17 @@ -<div id="termynal" data-termynal> -{{ with .Inner -}}{{ . | safeHTML }}{{- end }} +<div id="termynal-{{ urlize .Page.File.BaseFileName }}" data-termynal> + <div class="term-content"> + {{ if eq (.Get 0) "html" }} + {{ .Inner | safeHTML }} + {{ else }} + {{ with .Inner }} + {{ range (transform.Unmarshal .).lines }} + {{ if eq .type "progress" }} + <span data-ty="{{ .type }}" data-ty-delay="{{ .wait }}" data-ty-progressPercent="{{ .data }}"></span> + {{ else }} + <span data-ty="{{ .type }}" data-ty-delay="{{ .wait }}">{{ .data }}</span> + {{ end }} + {{ end }} + {{ end }} + {{ end }} + </div> </div>
\ No newline at end of file |