Last active
March 18, 2025 19:35
-
-
Save micheam/2cb4ee13729ecdd59ea952182564f9fc to your computer and use it in GitHub Desktop.
Hugo shortcode for CodeSandbox Embed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ $defaultWidth := "100%" }} | |
{{ $defaultHeight := "500px" }} | |
{{ if .IsNamedParams }} | |
<iframe | |
src="https://codesandbox.io/embed/{{ .Get "id" }}?codemirror=1&fontsize=13&hidenavigation=1&theme=dark&view=preview" | |
style="width:{{ with .Get "width" }}{{.}}{{ else }}100%{{ end }}; height:{{ with .Get "height" }}{{.}}{{ else }}{{ $defaultHeight }}{{ end }}; border:0; border-radius: 4px; overflow:hidden;" | |
title="{{ with .Get "title" }}{{.}}{{ else }}{{ .Get "id" }}{{ end }}" | |
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" | |
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin" | |
></iframe> | |
{{ else }} | |
<iframe | |
src="https://codesandbox.io/embed/{{ .Get 0 }}?codemirror=1&fontsize=13&hidenavigation=1&theme=dark&view=preview" | |
style="width:{{ $defaultWidth }}; height:{{ $defaultHeight }}; border:0; border-radius: 4px; overflow:hidden;" | |
title="{{ with .Get 1 }}{{.}}{{ else }}{{ .Get 0 }}{{ end }}" | |
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb" | |
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin" | |
></iframe> | |
{{ end }} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@michaelcaxias
Thank you! I fixed it 😄