This commit is contained in:
freearhey 2023-10-09 10:03:28 +03:00
parent b6b65a727a
commit 09f6d12085
7 changed files with 113 additions and 136 deletions

View file

@ -0,0 +1,24 @@
import { get } from 'svelte/store'
import { fetchChannels, channels } from '~/store'
import apiChannels from '~/data/channels.json'
export async function entries() {
return apiChannels
}
export async function load({ params }) {
const id = params.id
await fetchChannels()
const channel = get(channels).find(c => c.id === id)
let streams = []
if (channel) {
streams = channel._streams
}
return {
channel,
streams
}
}

View file

@ -4,27 +4,12 @@
import HTMLPreview from '~/components/HTMLPreview.svelte'
import EditButton from '~/components/EditButton.svelte'
import NavBar from '~/components/NavBar.svelte'
import { onMount } from 'svelte'
import { fetchChannels, channels } from '~/store'
import { page } from '$app/stores'
let channel
let isLoading = true
let streams = []
let guides = []
export let data
onMount(async () => {
const id = $page.url.searchParams.get('id')
if (id && !$channels.length) {
await fetchChannels()
}
channel = $channels.find(c => c.id === id)
if (channel) {
streams = channel._streams
guides = channel._guides
}
isLoading = false
})
let isLoading = false
let channel = data.channel
let streams = data.streams
</script>
<svelte:head>