@@ -3,9 +3,9 @@ title: Jamstack TV
33layout: layouts/base.njk
44---
55{# This search index data is populated by the code at https://github.com/netlify/jamstack-tv-search-data #}
6- {# <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected] /themes/reset-min.css" integrity="sha256-t2ATOGCtAIZNnzER679jwcFcKYfLlw01gli6F6oszk8=" crossorigin="anonymous"> #} 7- {# <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected] /themes/satellite-min.css" integrity="sha256-TehzF/2QvNKhGQrrNpoOb2Ck4iGZ1J/DI4pkd2oUsBc=" crossorigin="anonymous"> #} 8- < div class =" p-8 " >
6+
7+ < div class = " p-8 max-w-6xl mx-auto " >
8+ < h1 class =" text-center " > {{ title }} </ h1 >
99 <div id =" searchbox" ></div >
1010 <div id =" hits" ></div >
1111</div >
@@ -21,10 +21,25 @@ const search = instantsearch({
2121});
2222
2323{% raw % }
24+ function pad (num ) { return num < 10 ? ` 0${ num} ` : num; }
25+
26+ function getDurationString (duration ) {
27+ let secondsInOne = {
28+ hour: 60 * 60 ,
29+ minute: 60
30+ };
31+
32+ let hours = Math .floor (duration / secondsInOne .hour );
33+ let minutes = Math .floor ((duration % secondsInOne .hour ) / secondsInOne .minute );
34+ let seconds = Math .floor (duration % secondsInOne .minute );
35+
36+ return ` ${ hours ? ` ${ hours} :` : " " }${ hours ? pad (minutes) : minutes} :${ pad (seconds)} ` ;
37+ }
38+
2439search .addWidgets ([
2540 instantsearch .widgets .searchBox ({
2641 container: ' #searchbox' ,
27- placeholder: ' Search Video Content' ,
42+ // placeholder: 'Search Video Content',
2843 showReset: false ,
2944 showSubmit: false ,
3045 }),
@@ -43,20 +58,11 @@ search.addWidgets([
4358 let obj = {
4459 ... item,
4560 url: ` https://www.youtube.com/watch?v=${ item .video .id } }&t=${ start} s` ,
61+ displayDuration: getDurationString (item .video .duration ),
4662 };
4763
4864 if (start > 10 ) { // only show for deep links > 10 seconds
49- let secondsInOne = {
50- hour: 60 * 60 ,
51- minute: 60
52- }
53-
54- function pad (num ) { return num < 10 ? ` 0${ num} ` : num; }
55- let hours = Math .floor (start / secondsInOne .hour );
56- let minutes = Math .floor ((start % secondsInOne .hour ) / secondsInOne .minute );
57- let seconds = Math .floor (start % secondsInOne .minute );
58-
59- obj .displayStart = ` <span class="jamstacktv-time"><b></b><b></b>${ hours ? ` ${ pad (hours)} :` : " " }${ hours ? pad (minutes) : minutes} :${ pad (seconds)} </span>` ;
65+ obj .displayStartInline = ` <span class="jamstacktv-time"><b></b><b></b>${ getDurationString (start)} /</span>` ;
6066 // obj._highlightResult.caption.content = `…${obj._highlightResult.caption.content}`;
6167 } else {
6268 obj .wrapperClass = " jamstacktv-no-skip" ;
@@ -66,16 +72,17 @@ search.addWidgets([
6672 },
6773 templates: {
6874 item: `
69- <a href="{{ url }}" class="grid grid-cols-4 gap-4 mb-4 group">
70- <div class="aspect-ratio-youtube relative bg-gradient-card-sunrise card-shadow group-hover:card-shadow-sunrise jamstacktv-card">
71- <img src="{{ video.thumbnails.medium }}" alt="{{ video.title }}" class="absolute top-0 jamstacktv-img">
75+ <a href="{{ url }}" class="grid grid-cols-3 gap-4 mb-4 group">
76+ <div class="aspect-ratio-youtube relative jamstacktv-card">
77+ <img src="{{ video.thumbnails.medium }}" alt="{{ video.title }}" class="jamstacktv-img absolute top-0 card-shadow bg-gradient-card-sunrise group-hover:card-shadow-sunrise">
78+ <span class="jamstacktv-duration">{{{ displayStartInline }}}{{ displayDuration }}</span>
7279 </div>
73- <div class="col-span-3 jamstacktv-item {{ wrapperClass }}">
80+ <div class="col-span-2 jamstacktv-item {{ wrapperClass }}">
7481 <div class="jamstacktv-meta mb-1">
7582 <span class="jamstacktv-category">{{#helpers.highlight}}{ "attribute": "playlist.title" }{{/helpers.highlight}}</span>
7683 <span class="jamstacktv-title">{{#helpers.highlight}}{ "attribute": "video.title" }{{/helpers.highlight}}</span>
7784 </div>
78- <strong class="jamstacktv-caption">{{{ displayStart }}} <span class="jamstacktv-caption-quote">{{#helpers.highlight}}{ "attribute": "caption.content" }{{/helpers.highlight}}</span></strong>
85+ <strong class="jamstacktv-caption"><span class="jamstacktv-caption-quote">{{#helpers.highlight}}{ "attribute": "caption.content" }{{/helpers.highlight}}</span></strong>
7986 </div>
8087 </div>
8188 ` ,
0 commit comments