Skip to content

Commit

Permalink
feat: render list
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Apr 9, 2023
1 parent 7566a01 commit 66649a0
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@onekuma/preset.css": "^0.1.9",
"@onekuma/reset": "^0.1.9",
"@unocss/reset": "^0.51.0",
"animegarden": "workspace:*",
"unocss": "^0.51.0",
"vite-plugin-info": "^0.4.0"
}
Expand Down
27 changes: 27 additions & 0 deletions packages/app/src/components/ResourceTable.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
import type { Resource } from 'animegarden';
export interface Props {
resources: Resource[];
}
const { resources } = Astro.props;
---

<table>
<thead>
<tr>
<th>标题</th>
</tr>
</thead>
<tbody
>{
resources.map((r) => (
<tr>
<td>{r.title}</td>
</tr>
))
}</tbody
>
<tfoot></tfoot>
</table>
1 change: 1 addition & 0 deletions packages/app/src/constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const WORKER_BASE = `animegarden.yjl9903.workers.dev`;
2 changes: 1 addition & 1 deletion packages/app/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { title } = Astro.props;
<title>{title}</title>
</head>
<body>
<main class="main pt-16vh lt-lg:pt-4vh pb-8vh">
<main class="main pb-8vh">
<slot />
</main>
<footer class="main pb-8vh" select-none>
Expand Down
4 changes: 3 additions & 1 deletion packages/app/src/pages/api/[...path].ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { APIRoute } from 'astro';

import { WORKER_BASE } from '../../constant';

export const all: APIRoute = async ({ request }) => {
const url = new URL(request.url);
url.protocol = 'https:';
url.host = 'animegarden.yjl9903.workers.dev';
url.host = WORKER_BASE;
url.port = '';
url.pathname = url.pathname.replace(/^\/api/, '');

Expand Down
16 changes: 15 additions & 1 deletion packages/app/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
---
import type { Resource } from 'animegarden';
import Layout from '../layouts/Layout.astro';
import ResourceTable from '../components/ResourceTable.astro';
import { WORKER_BASE } from '../constant';
const resources = await fetch(new URL('/resources', 'https://' + WORKER_BASE))
.then((r) => r.json())
.then((r: any) => r.resources as Resource[]);
---

<Layout title="Anime Garden">
<div>Anime Garden</div>
<div class="mt-8vh">
<h1 class="text-4xl font-quicksand font-bold text-center select-none">🌸 Anime Garden</h1>
</div>

<div class="mt-8vh">
<ResourceTable resources={resources} />
</div>
</Layout>
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 66649a0

Please sign in to comment.