mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 18:18:37 +00:00
Improve inline resource examples (#1587)
This commit is contained in:
1 parent
2eae7c7ec0
commit
8262b077c6
1 file changed
+16
-1
@@ -60,7 +60,22 @@ RelPermalink
|
|||||||
: The relative URL to the resource. Resources of type `page` will have no value.
|
: The relative URL to the resource. Resources of type `page` will have no value.
|
||||||
|
|
||||||
Content
|
Content
|
||||||
: The content of the resource itself. For most resources, this returns a string with the contents of the file. This can be used to inline some resources, such as `<script>{{ (.Resources.GetMatch "myscript.js").Content | safeJS }}</script>` or `<img src="{{ (.Resources.GetMatch "mylogo.png").Content | base64Encode }}">`.
|
: The content of the resource itself. For most resources, this returns a string
|
||||||
|
with the contents of the file. Use this to create inline resources.
|
||||||
|
|
||||||
|
```go-html-template
|
||||||
|
{{ with .Resources.GetMatch "script.js" }}
|
||||||
|
<script>{{ .Content | safeJS }}</script>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ with .Resources.GetMatch "style.css" }}
|
||||||
|
<style>{{ .Content | safeCSS }}</style>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ with .Resources.GetMatch "img.png" }}
|
||||||
|
<img src="data:{{ .MediaType }};base64,{{ .Content | base64Encode }}">
|
||||||
|
{{ end }}
|
||||||
|
```
|
||||||
|
|
||||||
MediaType
|
MediaType
|
||||||
: The MIME type of the resource, such as `image/jpeg`.
|
: The MIME type of the resource, such as `image/jpeg`.
|
||||||
|
|||||||
Reference in new issue
Block a user