add preview_code shortcodes

This commit is contained in:
Tomoya Matsuura(MacBookPro) 2023-06-13 18:44:27 +09:00
parent 0912532389
commit ea1dce3f3b
2 changed files with 36 additions and 0 deletions

View File

@ -21,6 +21,13 @@ contentDir = 'content'
weight = 2 weight = 2
title = "Classes by Matsuura Tomoya" title = "Classes by Matsuura Tomoya"
[mediaTypes]
[mediaTypes.'text/ino']
suffixes = ['ino']
[mediaTypes.'text/pde']
suffixes = ['pde']
# (Optional) Set Google Analytics if you use it to track your website. # (Optional) Set Google Analytics if you use it to track your website.
# Always put it on the top of the configuration file, otherwise it won't work # Always put it on the top of the configuration file, otherwise it won't work

View File

@ -0,0 +1,29 @@
{{ $ref := "" }}
{{ $type := "" }}
{{ $target := "" }}
{{ with .Get "type" }}
{{ $type = . }}
{{ end }}
{{ with .Get "href" }}
{{ $ref = . }}
{{ $target = "_blank" }}
{{ end }}
{{ with .Get "relref" }}
{{ $ref = relref $ . }}
{{ end }}
<h3>{{ (path.Base $ref) | .Page.RenderString }}</h3>
<a {{ with $ref }} href="{{.}}" {{ end }} {{ with $target }} target="{{.}}" rel="noopener" {{ end }} class="book-btn{{ with .Get "class" }} {{ . }}{{ end }}">
DL
</a>
{{$page:=.Page}}
{{ with .Page.Resources.GetMatch $ref }}
{{( printf "```%s\n%s\n```\n" $type .Content ) | $page.RenderString}}
{{else}}
<p>file {{$ref}} not found </p>
{{ end }}