Skip to content

Commit

Permalink
Add remote file support to includes shortcode (#6)
Browse files Browse the repository at this point in the history
add new remote inlcudes shortcode support
  • Loading branch information
jtracey93 authored Nov 27, 2024
1 parent 0372ba7 commit 9ee1b8b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/layouts/shortcodes/include.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{ $file := .Get "file" }}
{{ $url := .Get "url" }}
{{ $type := .Get "type" }}
{{ $language := .Get "language" }}
{{ $options := .Get "options" }}

<div class="gdoc-include">
{{- if $url -}}
{{- $resource := resources.GetRemote $url -}}
{{- $content := $resource.Content -}}
{{- if $language -}}
{{- highlight $content $language (default "linenos=table" $options) -}}
{{- else if eq $type "html" -}}
{{- $content | safeHTML -}}
{{- else -}}
{{- $content -}}
{{- end -}}
{{- else -}}
{{- if $language -}}
{{- highlight ($file | readFile) $language (default "linenos=table" $options) -}}
{{- else if eq $type "html" -}}
{{- $file | readFile | safeHTML -}}
{{- else if eq $type "page" -}}
{{- with .Site.GetPage $file }}{{ .Content }}{{ end -}}
{{- else -}}
{{- $file | readFile | $.Page.RenderString -}}
{{- end -}}
{{- end -}}
</div>

0 comments on commit 9ee1b8b

Please sign in to comment.