5 changed files with 44 additions and 59 deletions
@ -1,26 +0,0 @@ |
|||||||
<script lang="ts"> |
|
||||||
import { page } from '$app/stores'; |
|
||||||
import Article from '$lib/components/Article.svelte'; |
|
||||||
import { ndk } from '$lib/ndk'; |
|
||||||
import type { NDKEvent } from '@nostr-dev-kit/ndk'; |
|
||||||
|
|
||||||
const id = $page.url.searchParams.get('id'); |
|
||||||
let event: NDKEvent | null | undefined; |
|
||||||
|
|
||||||
if (!id) { |
|
||||||
// TODO: Redirect to 400 page. |
|
||||||
} |
|
||||||
|
|
||||||
$ndk.fetchEvent(id!) |
|
||||||
.then(ev => { |
|
||||||
event = ev; |
|
||||||
}) |
|
||||||
.catch(err => { |
|
||||||
console.error(err); |
|
||||||
// TODO: Redirect to 404 page. |
|
||||||
}); |
|
||||||
</script> |
|
||||||
|
|
||||||
<main> |
|
||||||
<Article index={event} /> |
|
||||||
</main> |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
<script lang="ts"> |
|
||||||
import Article from '$lib/components/Article.svelte'; |
|
||||||
import { ndk } from '$lib/ndk'; |
|
||||||
import { TextPlaceholder } from 'flowbite-svelte'; |
|
||||||
import type { PageData } from './$types'; |
|
||||||
|
|
||||||
export let data: PageData; |
|
||||||
|
|
||||||
const getIndexEvent = (d: string) => { |
|
||||||
return $ndk.fetchEvent({ '#d': [d] }); |
|
||||||
}; |
|
||||||
</script> |
|
||||||
|
|
||||||
<main> |
|
||||||
{#await getIndexEvent(data.event.d)} |
|
||||||
<TextPlaceholder size='xxl' /> |
|
||||||
{:then index} |
|
||||||
<Article {index} /> |
|
||||||
{/await} |
|
||||||
</main> |
|
||||||
@ -1,11 +0,0 @@ |
|||||||
import type { PageLoad } from './$types'; |
|
||||||
|
|
||||||
export const load: PageLoad = async ({ params }) => { |
|
||||||
const { tag } = params; |
|
||||||
|
|
||||||
return { |
|
||||||
event: { |
|
||||||
d: tag, |
|
||||||
} |
|
||||||
}; |
|
||||||
}; |
|
||||||
@ -0,0 +1,42 @@ |
|||||||
|
<script lang="ts"> |
||||||
|
import { page } from '$app/stores'; |
||||||
|
import Article from '$lib/components/Article.svelte'; |
||||||
|
import { ndk } from '$lib/ndk'; |
||||||
|
import type { NDKEvent } from '@nostr-dev-kit/ndk'; |
||||||
|
import { TextPlaceholder } from 'flowbite-svelte'; |
||||||
|
|
||||||
|
const id = $page.url.searchParams.get('id'); |
||||||
|
const dTag = $page.url.searchParams.get('d'); |
||||||
|
|
||||||
|
let event: NDKEvent | null | undefined; |
||||||
|
|
||||||
|
if (id) { |
||||||
|
$ndk.fetchEvent(id) |
||||||
|
.then(ev => { |
||||||
|
event = ev; |
||||||
|
}) |
||||||
|
.catch(err => { |
||||||
|
console.error(err); |
||||||
|
// TODO: Redirect to 404 page. |
||||||
|
}); |
||||||
|
} else if (dTag) { |
||||||
|
$ndk.fetchEvent({ '#d': [dTag] }) |
||||||
|
.then(ev => { |
||||||
|
event = ev; |
||||||
|
}) |
||||||
|
.catch(err => { |
||||||
|
console.error(err); |
||||||
|
// TODO: Redirect to 404 page. |
||||||
|
}); |
||||||
|
} else { |
||||||
|
// TODO: Redirect to 400 page. |
||||||
|
} |
||||||
|
</script> |
||||||
|
|
||||||
|
<main> |
||||||
|
{#await event} |
||||||
|
<TextPlaceholder size='xxl' /> |
||||||
|
{:then ev} |
||||||
|
<Article index={ev} /> |
||||||
|
{/await} |
||||||
|
</main> |
||||||
Loading…
Reference in new issue