mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-14 02:50:07 -04:00
wip
This commit is contained in:
parent
b6b65a727a
commit
09f6d12085
7 changed files with 113 additions and 136 deletions
24
src/pages/channels/[id]/+page.server.js
Normal file
24
src/pages/channels/[id]/+page.server.js
Normal 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
|
||||
}
|
||||
}
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue