add preview_code shortcodes
This commit is contained in:
parent
0912532389
commit
ea1dce3f3b
@ -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
|
||||||
|
29
layouts/shortcodes/preview_code.html
Normal file
29
layouts/shortcodes/preview_code.html
Normal 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 }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user