@@ -18,12 +37,19 @@ class="wave" style="width: 100%; height: 155px; overflow: hidden;" href={`/watch/${video.videoId}`} - > + > + {#if loading} + + {:else if loaded} + + {:else} + Failed to load image + {/if} {#if !('liveVideo' in video) || !video.liveVideo} {videoLength(video.lengthSeconds)} @@ -40,7 +66,7 @@ - {truncate(video.title)} + {truncate(video.title)} {video.author}{#if !('publishedText' in video)} • {video.viewCountText}{/if} diff --git a/materialious/src/lib/misc.ts b/materialious/src/lib/misc.ts index 85ae2f27..e9fa7648 100644 --- a/materialious/src/lib/misc.ts +++ b/materialious/src/lib/misc.ts @@ -1,3 +1,7 @@ export function truncate(value: string, maxLength: number = 50): string { return value.length > maxLength ? `${value.substring(0, maxLength)}...` : value; +} + +export function numberWithCommas(number: number) { + return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } \ No newline at end of file diff --git a/materialious/src/routes/+layout.js b/materialious/src/routes/+layout.js deleted file mode 100644 index a3d15781..00000000 --- a/materialious/src/routes/+layout.js +++ /dev/null @@ -1 +0,0 @@ -export const ssr = false; diff --git a/materialious/src/routes/+layout.svelte b/materialious/src/routes/+layout.svelte index 94514255..ce564974 100644 --- a/materialious/src/routes/+layout.svelte +++ b/materialious/src/routes/+layout.svelte @@ -1,7 +1,5 @@ -{#if trending} +{#if data.trending} - {#each trending as video} + {#each data.trending as video} diff --git a/materialious/src/routes/+page.ts b/materialious/src/routes/+page.ts new file mode 100644 index 00000000..2af1817b --- /dev/null +++ b/materialious/src/routes/+page.ts @@ -0,0 +1,5 @@ +import { getTrending } from '$lib/Api/index.js'; + +export async function load({ params }) { + return { trending: await getTrending() }; +} \ No newline at end of file diff --git a/materialious/src/routes/watch/[slug]/+page.svelte b/materialious/src/routes/watch/[slug]/+page.svelte index 2b1daa92..e5c5ad15 100644 --- a/materialious/src/routes/watch/[slug]/+page.svelte +++ b/materialious/src/routes/watch/[slug]/+page.svelte @@ -1,30 +1,21 @@ -{#if video} - - - {video.title} - {video.description} - - - {#each video.recommendedVideos as recommendedVideo} - - {/each} - + + + {data.video.title} + + {numberWithCommas(data.video.viewCount)} views • {data.video.publishedText} + {data.video.description} + -{:else} - -{/if} + + {#each data.video.recommendedVideos as recommendedVideo} + + {/each} + + diff --git a/materialious/src/routes/watch/[slug]/+page.ts b/materialious/src/routes/watch/[slug]/+page.ts new file mode 100644 index 00000000..cbaa1688 --- /dev/null +++ b/materialious/src/routes/watch/[slug]/+page.ts @@ -0,0 +1,5 @@ +import { getVideo } from '$lib/Api/index.js'; + +export async function load({ params }) { + return { video: await getVideo(params.slug) }; +};
+ {numberWithCommas(data.video.viewCount)} views • {data.video.publishedText} + {data.video.description} +