Skip to content

Commit 59aff50

Browse files
committed
fix: register and login
1 parent 8e47d9c commit 59aff50

5 files changed

Lines changed: 53 additions & 8 deletions

File tree

new-deepnotes/apps/marketing/src/components/NavBar.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
import { computed, ref } from "vue";
33
import { useRoute } from "vue-router";
44
import { Button } from "@/components/ui/button";
5+
import { useAuthHint } from "@/composables/useAuthHint";
56
67
const route = useRoute();
7-
const appHref = computed(() => import.meta.env.VITE_WEB_APP_URL?.trim() || "/");
8+
const appBase = computed(() => import.meta.env.VITE_WEB_APP_URL?.trim().replace(/\/$/, "") || "/");
9+
const appHref = computed(() => appBase.value);
10+
const loginHref = computed(() => `${appBase.value}/login`);
11+
const registerHref = computed(() => `${appBase.value}/register`);
12+
const { isLoggedIn } = useAuthHint();
813
914
const navLinks = [
1015
{ to: "/pricing", label: "Pricing" },
@@ -109,9 +114,19 @@ function toggleTheme() {
109114
</svg>
110115
</button>
111116

112-
<Button as="a" :href="appHref" variant="default" size="sm">
113-
Open app
114-
</Button>
117+
<template v-if="isLoggedIn">
118+
<Button as="a" :href="appHref" variant="default" size="sm">
119+
Open app
120+
</Button>
121+
</template>
122+
<template v-else>
123+
<Button as="a" :href="loginHref" variant="ghost" size="sm">
124+
Log in
125+
</Button>
126+
<Button as="a" :href="registerHref" variant="default" size="sm">
127+
Get started
128+
</Button>
129+
</template>
115130
</div>
116131
</div>
117132
</header>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ref, onMounted } from "vue";
2+
3+
function readLoggedInCookie(): boolean {
4+
if (typeof document === "undefined") return false;
5+
return document.cookie.split("; ").some((c) => c.startsWith("loggedIn=true"));
6+
}
7+
8+
export function useAuthHint() {
9+
const isLoggedIn = ref(false);
10+
11+
onMounted(() => {
12+
isLoggedIn.value = readLoggedInCookie();
13+
});
14+
15+
return { isLoggedIn };
16+
}

new-deepnotes/apps/marketing/src/pages/HomePage.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { computed } from "vue";
33
import { useHead } from "@unhead/vue";
44
import { Button } from "@/components/ui/button";
5+
import { useAuthHint } from "@/composables/useAuthHint";
56
import {
67
Card,
78
CardContent,
@@ -10,7 +11,10 @@ import {
1011
CardTitle,
1112
} from "@/components/ui/card";
1213
13-
const appHref = computed(() => import.meta.env.VITE_WEB_APP_URL?.trim() || "/");
14+
const appBase = computed(() => import.meta.env.VITE_WEB_APP_URL?.trim().replace(/\/$/, "") || "/");
15+
const appHref = computed(() => appBase.value);
16+
const registerHref = computed(() => `${appBase.value}/register`);
17+
const { isLoggedIn } = useAuthHint();
1418
1519
useHead({
1620
title: "DeepNotes — End-to-end encrypted notes",
@@ -105,8 +109,16 @@ const useCases = [
105109
infinite canvas tool with deep nesting and real-time collaboration.
106110
</p>
107111
<div class="mt-8 flex flex-wrap items-center justify-center gap-3">
108-
<Button as="a" :href="appHref" size="lg"> Get started for free </Button>
109-
<Button as="a" :href="appHref" variant="outline" size="lg">
112+
<Button as="a" :href="registerHref" size="lg">
113+
Get started for free
114+
</Button>
115+
<Button
116+
v-if="isLoggedIn"
117+
as="a"
118+
:href="appHref"
119+
variant="outline"
120+
size="lg"
121+
>
110122
Open app
111123
</Button>
112124
</div>
@@ -170,7 +182,7 @@ const useCases = [
170182
Start organizing your thoughts on an infinite canvas, encrypted end to
171183
end.
172184
</p>
173-
<Button as="a" :href="appHref" size="lg" class="mt-8">
185+
<Button as="a" :href="registerHref" size="lg" class="mt-8">
174186
Get started — It&apos;s free!
175187
</Button>
176188
</section>

new-deepnotes/apps/marketing/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { defineConfig } from "vite";
88
const appRoot = fileURLToPath(new URL(".", import.meta.url));
99

1010
export default defineConfig({
11+
envDir: '../..',
1112
plugins: [vue(), tailwindcss()],
1213
resolve: {
1314
alias: {

new-deepnotes/apps/web/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { defineConfig } from "vitest/config";
88
const appRoot = fileURLToPath(new URL(".", import.meta.url));
99

1010
export default defineConfig({
11+
envDir: '../..',
1112
plugins: [vue(), tailwindcss()],
1213
resolve: {
1314
alias: {

0 commit comments

Comments
 (0)