WIP d58a8273
Steve · 2024-09-19 23:37 2 file(s) · +40 −31
src/components/SignInButton.tsx +16 −18
1 -
import { createClient } from "@supabase/supabase-js";
1 +
// import { supabase } from "src/lib/supabase";
2 2
3 -
export function SignInButton({ supabaseUrl, supabaseAnonKey }) {
4 -
	const supabase = createClient(supabaseUrl || "", supabaseAnonKey || "");
5 -
6 -
	async function signInWithGithub() {
7 -
		await supabase.auth.signInWithOAuth({
8 -
			provider: "github",
9 -
			options: {
10 -
				redirectTo: "https://stevedylan.dev/auth/callback",
11 -
			},
12 -
		});
13 -
	}
3 +
// export function SignInButton() {
4 +
// 	async function signInWithGithub() {
5 +
// 		await supabase.auth.signInWithOAuth({
6 +
// 			provider: "github",
7 +
// 			options: {
8 +
// 				redirectTo: "https://stevedylan.dev/auth/callback",
9 +
// 			},
10 +
// 		});
11 +
// 	}
14 12
15 -
	return (
16 -
		<button type="button" onClick={signInWithGithub}>
17 -
			Sign In
18 -
		</button>
19 -
	);
20 -
}
13 +
// 	return (
14 +
// 		<button type="button" onClick={signInWithGithub}>
15 +
// 			Sign In
16 +
// 		</button>
17 +
// 	);
18 +
// }
src/pages/log.astro +24 −13
1 1
---
2 2
import PageLayout from "@/layouts/Base";
3 -
import { SignInButton } from "src/components/SignInButton";
4 -
const { env } = Astro.locals.runtime;
5 3
6 4
const meta = {
7 5
	title: "Log",
8 6
	description: "Public Log",
9 7
};
8 +
---
10 9
11 -
const supabaseUrl =
12 -
	env.PUBLIC_SUPABASE_URL || import.meta.env.PUBLIC_SUPABASE_URL || "";
13 -
const supabaseAnonKey =
14 -
	env.PUBLIC_SUPABASE_ANON_KEY ||
15 -
	import.meta.env.PUBLIC_SUPABASE_ANON_KEY ||
16 -
	"";
17 -
---
10 +
<script>
11 +
  import { createClient } from '@supabase/supabase-js';
12 +
13 +
  const supabase = createClient(
14 +
    Astro.locals.runtime.env.PUBLIC_SUPABASE_URL,
15 +
    Astro.locals.runtime.env.PUBLIC_SUPABASE_ANON_KEY
16 +
  );
17 +
18 +
  async function signInWithGithub() {
19 +
    await supabase.auth.signInWithOAuth({
20 +
      provider: "github",
21 +
      options: {
22 +
        redirectTo: "https://stevedylan.dev/auth/callback",
23 +
      },
24 +
    });
25 +
  }
26 +
27 +
  document.getElementById('signInButton').addEventListener('click', signInWithGithub);
28 +
</script>
29 +
18 30
19 31
<PageLayout meta={meta}>
20 32
	<div class="space-y-6">
21 -
  	<SignInButton
22 -
   supabaseUrl={supabaseUrl}
23 -
   supabaseAnonKey={supabaseAnonKey}
24 -
      client:load />
33 +
	<button type="button" id="signInButton">Sign In</button>
34 +
		Sign In
35 +
	</button>
25 36
	</div>
26 37
</PageLayout>