From 8f5278eb443864910dd9c2131c992d71e3af2d20 Mon Sep 17 00:00:00 2001 From: kartofen Date: Fri, 26 Aug 2022 23:54:17 +0300 Subject: Big bang --- src/pages/404.md | 1 + src/pages/board/[board].astro | 26 ++++++++++ src/pages/board/[board]/[tid].astro | 26 ++++++++++ src/pages/boards.astro | 32 ++++++++++++ src/pages/index.astro | 101 ++++++++++++++++++++++++++++++++++++ 5 files changed, 186 insertions(+) create mode 100644 src/pages/404.md create mode 100644 src/pages/board/[board].astro create mode 100644 src/pages/board/[board]/[tid].astro create mode 100644 src/pages/boards.astro create mode 100644 src/pages/index.astro (limited to 'src/pages') diff --git a/src/pages/404.md b/src/pages/404.md new file mode 100644 index 0000000..3061d00 --- /dev/null +++ b/src/pages/404.md @@ -0,0 +1 @@ +# 404 Error 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); +--- + + +

{board}

+ + {threads.map((thread) => ( + + ))} + +
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; +--- + + + + {comments.map((comment) => ( + + ))} + + diff --git a/src/pages/boards.astro b/src/pages/boards.astro new file mode 100644 index 0000000..ab3158f --- /dev/null +++ b/src/pages/boards.astro @@ -0,0 +1,32 @@ +--- +import Default from '../layouts/Default.astro'; +import { api } from '../lib/api.ts'; + +const data = await api('get', 'boards'); +const boards: string[] = await data.json(); +--- + + +
+

Boards

+ +
    + {boards.map((board) => ( +
  • {board}
  • + ))} +
+
+
+ + diff --git a/src/pages/index.astro b/src/pages/index.astro new file mode 100644 index 0000000..4dfffe3 --- /dev/null +++ b/src/pages/index.astro @@ -0,0 +1,101 @@ +--- +import Layout from '../layouts/Layout.astro'; +import Card from '../components/Card.astro'; +--- + + +
+

Welcome to Astro

+

+ Check out the src/pages directory to get started.
+ Code Challenge: Tweak the "Welcome to Astro" message above. +

+ +
+
+ + -- cgit v1.2.3