summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authoramzrk22020-04-20 19:08:56 +0800
committeramzrk22020-04-20 19:08:56 +0800
commit71ae6d1e825fdb782328653f121651dc515b29e9 (patch)
tree6034b286caf5803c29469821b49d99a717d7ac92 /README.md
parent338f934a2a252b018af2cba56eac956577780147 (diff)
downloadhugo-theme-fuji-71ae6d1e825fdb782328653f121651dc515b29e9.tar.gz
hugo-theme-fuji-71ae6d1e825fdb782328653f121651dc515b29e9.tar.bz2
hugo-theme-fuji-71ae6d1e825fdb782328653f121651dc515b29e9.zip
Optional lazy image instead of global set
Diffstat (limited to 'README.md')
-rw-r--r--README.md22
1 files changed, 16 insertions, 6 deletions
diff --git a/README.md b/README.md
index 01d4502..3caba0a 100644
--- a/README.md
+++ b/README.md
@@ -53,18 +53,28 @@ $ hugo --minify
## Advance configration
-You can create the files below in your site to adjust the markdown render hook, see [Hugo's Official Docs](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks).
+### Lazyload images
-You can use ```layouts/_default/_markup/render-link.html``` to decide whether or not links in the markdown content will open in new tab:
+Lazyload images in posts, for example in ```content/post/test.md```:
-```html
-<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text | safeHTML }}</a>
+```go-html-template
+{{< lazyimg "This is alt text" "/img/sample.png" >}}
+{{< lazyimg-row "This is alt text" "/img/sample.png" >}}
+{{< lazyimg-col "This is alt text" "/img/sample.png" >}}
```
-You can use ```layouts/_default/_markup/render-image.html``` to change the lazyload placeholder:
+```lazyimg``` will show a 16x9 placeholder before image is loaded, so ```lazyimg-row``` will show a 32x9 placeholder and ```lazyimg-col``` will show a 8x9 placeholder. You can choose different aspect ratios you want for different images. The placeholder image can be set in site's ```config.toml```.
+
+Note that if you use the origin markdown syntax to add images such as ```![This is alt text](/img/sample.png)```, it will not become a lazy image.
+
+### Markdown render hook
+
+You can create the files below in your site to adjust the markdown render hook, see [Hugo's Official Docs](https://gohugo.io/getting-started/configuration-markup#markdown-render-hooks).
+
+You can use ```layouts/_default/_markup/render-link.html``` to decide whether or not links in the markdown content will open in new tab:
```html
-<p><img class="lazy" src="https://cdn.jsdelivr.net/gh/amzrk2/poal-jsdelivr@1.0.0/lazyload/dsr_loading.svg" data-src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}"{{ end }} /></p>
+<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank"{{ end }}>{{ .Text | safeHTML }}</a>
```
## Update the theme