Continue porting from V1
This commit is contained in:
9
web/src/components/BaseHead.astro
Normal file
9
web/src/components/BaseHead.astro
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
import "../styles/global.css"
|
||||
---
|
||||
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>Astro</title>
|
||||
15
web/src/components/Header.astro
Normal file
15
web/src/components/Header.astro
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
<div class="flex w-full items-center bg-[#2a2b2c] text-white p-5">
|
||||
<a class="flex" href="/">
|
||||
<p class="text-3xl">Recipie</p>
|
||||
<!-- <p class=" text-3xl text-amber-500">pie</p> -->
|
||||
🥧
|
||||
</a>
|
||||
|
||||
<div class="ml-auto space-x-5">
|
||||
<a class="hover:underline underline-offset-4" href="/recipe/new">new</a>
|
||||
<a class="hover:underline underline-offset-4" href="/recipe/import">add</a>
|
||||
<!-- <a class="hover:underline underline-offset-4" href="/tags">tags</a> -->
|
||||
<a class="hover:underline underline-offset-4" >search</a>
|
||||
</div>
|
||||
</div>
|
||||
16
web/src/data/pb.ts
Normal file
16
web/src/data/pb.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import PocketBase from "pocketbase";
|
||||
|
||||
console.log("STUFF", import.meta.env.PUBLIC_PB_URL)
|
||||
|
||||
const pb = new PocketBase(import.meta.env.PUBLIC_PB_URL);
|
||||
pb.autoCancellation(false)
|
||||
|
||||
export const authPB = async () => {
|
||||
if (!pb.authStore.isValid) {
|
||||
await pb.collection('users').authWithPassword(
|
||||
import.meta.env.PB_EMAIL,
|
||||
import.meta.env.PB_PW
|
||||
);
|
||||
}
|
||||
return pb;
|
||||
};
|
||||
18
web/src/layouts/Base.astro
Normal file
18
web/src/layouts/Base.astro
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
import BaseHead from '@component/BaseHead'
|
||||
import Header from '@component/Header'
|
||||
---
|
||||
|
||||
<html lang=en>
|
||||
<head>
|
||||
<BaseHead title="Recipie" />
|
||||
</head>
|
||||
<body>
|
||||
<main id="main" class="flex-1">
|
||||
<Header/>
|
||||
<div class="px-3 mb-5 md:px-5 pt-2">
|
||||
<slot />
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
19
web/src/pages/api/[...proxy].ts
Normal file
19
web/src/pages/api/[...proxy].ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const getProxyUrl = (request: Request) => {
|
||||
const proxyUrl = new URL(import.meta.env.PUBLIC_PB_URL);
|
||||
const requestUrl = new URL(request.url);
|
||||
return new URL(requestUrl.pathname + requestUrl.search, proxyUrl);
|
||||
};
|
||||
|
||||
export const ALL: APIRoute = async ({ request }) => {
|
||||
const proxyUrl = getProxyUrl(request);
|
||||
const response = await fetch(proxyUrl.href, request);
|
||||
return new Response(response.body, {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
headers: response.headers
|
||||
});
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
---
|
||||
import { authPB } from "@data/pb";
|
||||
|
||||
const pb = await authPB()
|
||||
---
|
||||
|
||||
<html lang="en">
|
||||
|
||||
@@ -1 +1,14 @@
|
||||
@import "tailwindcss";
|
||||
@import "tailwindcss";
|
||||
|
||||
html {
|
||||
@apply bg-[#1d1f21];
|
||||
/* @apply bg-[#fafafa]; */
|
||||
@apply text-white;
|
||||
/* @apply font-; */
|
||||
@apply font-sans;
|
||||
/* font-family: 'SF Pro Display', 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; */
|
||||
}
|
||||
|
||||
.title {
|
||||
@apply text-2xl;
|
||||
}
|
||||
@@ -1,5 +1,14 @@
|
||||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"]
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@component/*": ["src/components/*.astro"],
|
||||
"@layout/*": ["src/layouts/*.astro"],
|
||||
"@utils": ["src/utils/index.ts"],
|
||||
"@data/*": ["src/data/*"],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user