Skip to content

Commit 48dcb1e

Browse files
André DietrichAndré Dietrich
authored andcommitted
add shortcodes for liascript
1 parent 86a8a2e commit 48dcb1e

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{/*
2+
liascript-show – LiaScript LiveEditor shortcode für externe Dateien (show/file Modus)
3+
4+
Öffnet eine externe LiaScript-Datei (z.B. ein GitHub-Raw-URL) im LiveEditor.
5+
6+
Verwendung:
7+
{{< liascript-show "https://raw.githubusercontent.com/LiaTemplates/ABCjs/main/README.md" >}}
8+
{{< liascript-show url="https://raw.githubusercontent.com/..." >}}
9+
10+
Optionaler Parameter:
11+
height="80vh" (Standard)
12+
*/}}
13+
14+
{{ $height := (.Get "height") | default "80vh" }}
15+
{{ $url := .Get "url" | default (index .Params 0) }}
16+
{{ $src := printf "https://liascript.github.io/LiveEditor/?/show/file/%s" $url }}
17+
18+
<iframe
19+
style="height: {{ $height }}; min-width: 100%; border: 1px black solid"
20+
src="{{ $src }}"></iframe>

layouts/shortcodes/liascript.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{/*
2+
liascript – LiaScript LiveEditor embed shortcode (embed/code Modus)
3+
4+
Eingebetteter Quelltext wird als base64 kodiert und als embed/code URL geöffnet.
5+
6+
Verwendung:
7+
{{< liascript >}}
8+
<!--
9+
import: https://...
10+
-->
11+
12+
# Titel
13+
14+
``` abc
15+
X: 1
16+
...
17+
```
18+
@ABCJS.render
19+
{{< /liascript >}}
20+
21+
Optionale Parameter:
22+
height="80vh" (Standard)
23+
mode="" Editor + Vorschau (Standard)
24+
mode="edit" nur Editor
25+
mode="preview" nur Vorschau
26+
*/}}
27+
28+
{{ $height := (.Get "height") | default "80vh" }}
29+
{{ $mode := .Get "mode" | default "" }}
30+
{{ $suffix := "" }}
31+
{{ if eq $mode "edit" }}
32+
{{ $suffix = "/edit" }}
33+
{{ else if eq $mode "preview" }}
34+
{{ $suffix = "/preview" }}
35+
{{ end }}
36+
{{ $code := trim .Inner "\n" }}
37+
{{ $src := printf "https://liascript.github.io/LiveEditor/?/embed/code%s/%s" $suffix ($code | base64Encode) }}
38+
39+
<iframe
40+
style="height: {{ $height }}; min-width: 100%; border: 1px black solid"
41+
src="{{ $src }}"></iframe>

0 commit comments

Comments
 (0)