butiran-✗

svg-include shortcode

· 1 min read · edit

result

usage

{{< svg/includev1 "images/inhouse/01-the-birth-of-me.svg" >}}

code

{{ $file := printf "static/%s" (.Get 0) }}

<div class="svg-container">
  {{ with readFile $file }}
    {{ . | safeHTML }}
  {{ else }}
    <!-- SVG file not found: {{ .Get 0 }} -->
  {{ end }}
</div>

<style>
.svg-container {
  width: 100%;
}

.svg-container svg {
  display: block;
  width: 100%;
  height: auto;
}
</style>

refs