4242 {{> partials/weather in = .}}
4343 </div >
4444
45- <a class =" images is-preview is-{{ size-class (size images )}} " href =" {{ route this }} " >
46- {{ #with images.0 }}
47- <div class =" {{ #if is.video }} is-video{{ /if }} image" >
48- <img alt =" {{ title }} , {{ date meta.dateTime format =' d.m.Y H:i' }} " {{ #unless first }} loading =" lazy" {{ /unless }} {{ &dataset meta }} src =" /image/{{ slug }} /thumb-{{ name }} .webp" width =" 1024" >
49- </div >
50- {{ /with }}
51- <div class =" more" >
52- {{ #each images }}
53- {{ #unless (equals @index 0 )}}
54- <img alt =" {{ title }} , {{ date meta.dateTime format =' d.m.Y H:i' }} " {{ #unless ../@first }} loading =" lazy" {{ /unless }} style =" z-index: -{{ @index }} " src =" /image/{{ slug }} /thumb-{{ name }} .webp" width =" 192" >
55- {{ /unless }}
56- {{ /each }}
45+ {{! Content formed of a single video can be played back inline directly }}
46+ {{ #if (all (equals 1 (size images )) images.0.is.video )}}
47+ <div class =" images is-single" >
48+ {{ #with images.0 }}
49+ <div class =" image" >
50+ <video controls playsinline preload =" metadata" width =" 100%" poster =" /image/{{ slug }} /thumb-{{ name }} .webp" data-slug =" {{ slug }} " >
51+ <source src =" /image/{{ slug }} /video-{{ name }} .mp4" type =" video/mp4" >
52+ </video >
53+ </div >
54+ {{ /with }}
5755 </div >
58- </a >
56+ {{ else }}
57+ <a class =" images is-preview is-{{ size-class (size images )}} " href =" {{ route this }} " >
58+ {{ #with images.0 }}
59+ <div class =" {{ #if is.video }} is-video{{ /if }} image" >
60+ <img alt =" {{ title }} , {{ date meta.dateTime format =' d.m.Y H:i' }} " {{ #unless first }} loading =" lazy" {{ /unless }} {{ &dataset meta }} src =" /image/{{ slug }} /thumb-{{ name }} .webp" width =" 1024" >
61+ </div >
62+ {{ /with }}
63+ <div class =" more" >
64+ {{ #each images }}
65+ {{ #unless (equals @index 0 )}}
66+ <div class =" {{ #if is.video }} is-video{{ /if }} image" style =" z-index: -{{ @index }} " >
67+ <img alt =" {{ title }} , {{ date meta.dateTime format =' d.m.Y H:i' }} " {{ #unless ../@first }} loading =" lazy" {{ /unless }} src =" /image/{{ slug }} /thumb-{{ name }} .webp" width =" 192" >
68+ </div >
69+ {{ /unless }}
70+ {{ /each }}
71+ </div >
72+ </a >
73+ {{ /if }}
5974
6075 <div class =" content" >
6176 {{ & content }}
7590 </div >
7691 {{ /inline }}
7792 {{ #*inline " scripts" }}
93+ <script type =" module" >
94+ {{& use ' statistics' }}
95+ const statistics = new Statistics ();
96+ {{#each elements}}
97+ {{#if (all (equals 1 (size images)) images.0 .is .video )}}
98+ statistics .add (' {{slug}}' , ' {{sign slug}}' , 1500 );
99+ {{/ if }}
100+ {{/ each}}
101+
102+ // Content formed of a single video has been watched once it's played back for more than 1.5 seconds
103+ for (const $video of document .querySelectorAll (' video' )) {
104+ $video .addEventListener (' play' , e => statistics .schedule ($video .dataset [' slug' ]));
105+ $video .addEventListener (' pause' , e => statistics .withdraw ($video .dataset [' slug' ]));
106+ }
107+ </script >
78108 {{ /inline }}
79109{{ /layout }}
0 commit comments