Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use env vars to infer the sign in/up paths for the mounted components #98

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brave-tigers-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-clerk-auth": patch
---

Use the environmenta variables to infer the correct paths for the `SignIn/Up` components.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Layout from "../../layouts/Layout.astro";
<Layout title="Welcome to Astro.">
<ClerkLayout>
<div class="w-full flex justify-center">
<SignIn path='/sign-in' />
<SignIn />
</div>
</ClerkLayout>
</Layout>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Layout from "../../layouts/Layout.astro";
<Layout title="Welcome to Astro.">
<ClerkLayout>
<div class="w-full flex justify-center">
<SignUp path='/sign-up' />
<SignUp />
</div>
</ClerkLayout>
</Layout>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UserJSON from "../../components/UserJSON.astro";
<Protected>
<ClerkLayout protectedPage={true}>
<div class="w-full flex justify-center">
<UserProfile path="/user" routing="path" />
<UserProfile routing="hash" />
</div>
<UserJSON />
</ClerkLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
import type { SignInProps } from "@clerk/types";
type Props = SignInProps;

import { signUpUrl } from "astro-clerk-auth/v0";
import { signUpUrl, signInUrl } from "astro-clerk-auth/v0";
import { customAlphabet, urlAlphabet } from "nanoid";

const safeId = customAlphabet(urlAlphabet, 10)();

const props = {
const serverProps = {
...Astro.props,
path: Astro.props.path || signInUrl,
signUpUrl: Astro.props.signUpUrl || signUpUrl
}
---

<div id={`clerk-sign-in-${safeId}`}></div>

<script is:inline define:vars={{ props: Astro.props, safeId }}>
<script is:inline define:vars={{ props:serverProps , safeId }}>
const setOrCreatePropMap = ({ category, id, props }) => {
if (!window.__astro_clerk_component_props) {
window.__astro_clerk_component_props = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
import type { SignUpProps } from "@clerk/types";
type Props = SignUpProps;

import { signInUrl } from "astro-clerk-auth/v0";
import { signInUrl, signUpUrl } from "astro-clerk-auth/v0";
import { customAlphabet, urlAlphabet } from "nanoid";

const safeId = customAlphabet(urlAlphabet, 10)();

const props = {
const serverProps = {
...Astro.props,
path: Astro.props.path || signUpUrl,
signInUrl: Astro.props.signInUrl || signInUrl
}
---

<div id={`clerk-sign-up-${safeId}`}></div>

<script is:inline define:vars={{ props: Astro.props, safeId }}>
<script is:inline define:vars={{ props: serverProps, safeId }}>
const setOrCreatePropMap = ({ category, id, props }) => {
if (!window.__astro_clerk_component_props) {
window.__astro_clerk_component_props = new Map();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { SignInProps } from "@clerk/types";
type Props = SignInProps

import { signUpUrl } from "astro-clerk-auth/v0";
import { signUpUrl, signInUrl } from "astro-clerk-auth/v0";
import { SignIn as SignInReact } from "astro-clerk-auth/client/react";
/**
* For React component, in order to avoid hydration errors populate SSR store and do not depend on the component being wrapped ClerkLayout.
Expand All @@ -14,6 +14,7 @@ __internal_authAsyncStorage.enterWith(Astro.locals.auth())

const props = {
...Astro.props,
path: Astro.props.path || signInUrl,
signUpUrl: Astro.props.signUpUrl || signUpUrl
}
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { SignUpProps } from "@clerk/types";
type Props = SignUpProps

import { signInUrl } from "astro-clerk-auth/v0";
import { signInUrl, signUpUrl } from "astro-clerk-auth/v0";
import { SignUp as SignUpReact } from "astro-clerk-auth/client/react";
/**
* For React component, in order to avoid hydration errors populate SSR store and do not depend on the component being wrapped ClerkLayout.
Expand All @@ -14,6 +14,7 @@ __internal_authAsyncStorage.enterWith(Astro.locals.auth())

const props = {
...Astro.props,
path: Astro.props.path || signUpUrl,
signInUrl: Astro.props.signInUrl || signInUrl
}
---
Expand Down
Loading