feat(exampleSite): provide more extensive examples

This commit is contained in:
kdevo
2021-10-09 16:27:12 +02:00
parent b0bc22384f
commit 512ea96384
4 changed files with 86 additions and 55 deletions
+17
View File
@@ -0,0 +1,17 @@
---
title: Test Content Page
draft: false
---
### This is just some example how to use the shortcode.
{{< lorem 5 >}}
{{< lazyimg img="images/alps.jpg" >}}
{{< lorem 3 >}}
<!-- Override some parameters: -->
{{< lazyimg img="images/alps.jpg" maxSize="640x" alt="mountains" class="smaller-img" renderer="lqip-webp" >}}
{{< lorem 3 >}}
-55
View File
@@ -1,55 +0,0 @@
<!doctype html>
<!-- The 'no-js' class will be removed on lazyimg-setup: -->
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hugo-mods: lazyimg</title>
<style>
/* TODO(kdevo): create a nice flexbox image gallery example
/* .grid {
display: flex;
flex-flow: column;
justify-content: space-between;
}
.item {
width: 50%;
flex-grow: 1;
height: auto;
max-width: 1024px;
} */
html {
box-sizing: border-box;
}
img {
height: auto;
width: 100%;
max-width: 1920px;
border-radius: 5px;
border: 1px solid #aaa;
}
</style>
<!-- lazyimg.css ensures that the image is not displayed twice when the user has no-js: -->
<style>{{ (resources.Get "lazyimg.css" | minify).Content | safeCSS }}</style>
<!-- This script basically loads laszysizes asynchronously: -->
{{ partial "lazyimg-setup-nojs" . }}
</head>
<body>
<!-- Most basic usage with single parameter that can either be a filename or resource: -->
{{ partial "lazyimg" "images/alps.jpg" }}
<!-- Here we call the partial by passing a param dict that overrides the site's params: -->
{{ partial "lazyimg" (dict "img" "images/alps.jpg" "class" "my-fancy-class" "alt" "This image shows the alps" "resizer" "simple") }}
{{ $images := (partial "images" .) }}
{{ range $images -}}
<!-- Here we call the partial with a resource: -->
{{ partial "lazyimg" . }}
{{- end }}
</body>
</html>
+30
View File
@@ -0,0 +1,30 @@
<!doctype html>
<!-- The 'no-js' class will be removed on lazyimg-setup: -->
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>hugo-mods: lazyimg - {{ .Title }}</title>
<style>
.container {
max-width: 47em;
margin: auto;
padding: 32px;
text-justify: newspaper;
}
img {
height: auto;
width: 100%;
}
{{ (resources.Get "lazyimg.css" | minify).Content | safeCSS }}
</style>
<script>document.documentElement.className = "js"</script>
<!-- This script basically loads laszysizes asynchronously: -->
{{ partial "lazyimg-setup" . }}
</head>
<body class="container">
<h1>{{ .Title }}</h1>
{{ .Content }}
</body>
</html>
+39
View File
@@ -0,0 +1,39 @@
<!doctype html>
<!-- The 'no-js' class will be removed on lazyimg-setup: -->
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>hugo-mods: lazyimg</title>
<style>
/* Style image as you like, but note the height and width for responsiveness: */
img {
height: auto;
width: 100%;
max-width: 1920px;
border-radius: 5px;
border: 1px solid #aaa;
}
/* lazyimg.css ensures that the image is not displayed twice when the user has no-js: */
{{ (resources.Get "lazyimg.css" | minify).Content | safeCSS }}
</style>
<!-- This script basically loads laszysizes asynchronously: -->
{{ partial "lazyimg-setup-nojs" . }}
</head>
<body>
<!-- Most basic usage with single parameter that can either be a filename or resource: -->
{{ partial "lazyimg" "images/alps.jpg" }}
<!-- Here we call the partial by passing a param dict that overrides the site's params: -->
{{ partial "lazyimg" (dict "img" "images/alps.jpg" "class" "my-fancy-class" "alt" "This image shows the alps" "resizer" "simple") }}
{{ $images := (partial "images" .) }}
{{ range $images -}}
<!-- Here we call the partial with a resource: -->
{{ partial "lazyimg" . }}
{{- end }}
</body>
</html>