diff options
Diffstat (limited to 'src/pages/board')
| -rw-r--r-- | src/pages/board/[board].astro | 26 | ||||
| -rw-r--r-- | src/pages/board/[board]/[tid].astro | 26 | 
2 files changed, 52 insertions, 0 deletions
| diff --git a/src/pages/board/[board].astro b/src/pages/board/[board].astro new file mode 100644 index 0000000..2624fed --- /dev/null +++ b/src/pages/board/[board].astro @@ -0,0 +1,26 @@ +--- +import Default from '../../layouts/Default.astro'; +import Thread from '../../components/Thread.svelte' +import type Thread from '../../models/Thread'; + +import { api } from '../../lib/api.ts'; +import { processThreadIn } from '../../lib/thread' + +const { board } = Astro.params; +const data = await api('get', `board/${board}`); + +if(data.status === 404) return Astro.redirect('/404'); + +const threads: Thread[] = await data.json(); +for(let thread of threads) +  await processThreadIn(board, thread); +--- + +<Default> +  <h1><a href="/boards"> {board} </a></h1> + +  {threads.map((thread) => ( +    <Thread thread={thread} board={board} /> +  ))} + +</Default> diff --git a/src/pages/board/[board]/[tid].astro b/src/pages/board/[board]/[tid].astro new file mode 100644 index 0000000..80e7fbe --- /dev/null +++ b/src/pages/board/[board]/[tid].astro @@ -0,0 +1,26 @@ +--- +import Default from '../../../layouts/Default.astro'; +import Thread from '../../../components/Thread.svelte' +import Comment from '../../../components/Comment.svelte' +import type Thread from '../../../models/Thread'; + +import { api } from '../../../lib/api'; +import { processThreadIn } from '../../../lib/thread'; + +const { board } = Astro.params; +const data = await api('get', `thread/${board}/${Astro.params.tid}`); + +if(data.status === 404) return Astro.redirect('/404'); + +const thread: Thread = await data.json(); +await processThreadIn(board, thread, true); +const comments: Comment[] = thread.comments; +--- + +<Default> +  <Thread thread={thread} board={board}> +    {comments.map((comment) => ( +      <Comment comment={comment} /> +    ))} +  </Thread> +</Default> | 
