forked from jargonsdev/jargons.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.astro
40 lines (35 loc) · 1.36 KB
/
index.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
import BaseLayout from "../../../layouts/base.astro";
import doAuth from "../../../lib/actions/do-auth.js";
import Navbar from "../../../components/navbar.astro";
import { resolveEditorActionFromPathname } from "../../../lib/utils/index.js";
import WordEditor, { SubmitButton as WordEditorSubmitButton, TogglePreview } from "../../../components/islands/word-editor.jsx";
const { url: { pathname }, redirect } = Astro;
const { isAuthed, authedData: userData } = await doAuth(Astro);
if (!isAuthed) return redirect(`/login?return_to=${encodeURIComponent(pathname)}`);
const action = resolveEditorActionFromPathname(pathname);
---
<BaseLayout
pageTitle="Dictionry"
class="flex flex-col w-full min-h-screen overflow-hidden"
>
<Navbar
returnNav={{
/**
* @todo now this looks weirds the commit link below - the `editor/new` route can now be reached from places..
* ..other than the jargons editor page.
* @link https://github.com/babblebey/jargons.dev/pull/60/commits/6e1ccf74f31c6b8da4b42bc1ffdc0efbf16b19ac
*/
label: "Back to Jargons Editor",
location: "/editor"
}}
>
<div class="flex space-x-3">
<TogglePreview client:load />
<WordEditorSubmitButton client:load />
</div>
</Navbar>
<main class="flex grow px-5 md:px-6 pb-4">
<WordEditor action={action} client:load />
</main>
</BaseLayout>