Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
test: auth-astro sign in on index page
Browse files Browse the repository at this point in the history
  • Loading branch information
hetd54 committed Sep 18, 2024
1 parent 7db15dc commit c9fd46f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
22 changes: 11 additions & 11 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import tailwind from "@astrojs/tailwind";
import react from "@astrojs/react";
import auth from "auth-astro";
import { defineConfig } from "astro/config"
import mdx from "@astrojs/mdx"
import sitemap from "@astrojs/sitemap"
import tailwind from "@astrojs/tailwind"
import react from "@astrojs/react"
import auth from "auth-astro"

import node from "@astrojs/node";
import node from "@astrojs/node"

// https://astro.build/config
export default defineConfig({
site: "https://example.com",
output: "hybrid",
output: "server",
integrations: [mdx(), sitemap(), tailwind(), react(), auth()],
adapter: node({
mode: "standalone"
})
});
mode: "standalone",
}),
})
11 changes: 11 additions & 0 deletions public/admin/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import { signIn } from "../../node_modules/auth-astro/client.ts"
import { PeoplePreview } from "./previews/PeoplePreview.js"
import { NewsPreview } from "./previews/NewsPreview.js"

console.log("HI WE ARE HERE DOING THINGS")

if (document.body.contains(document.querySelector(".CMS_Login_button"))) {
console.log("IT IS HERE")
}
document.getElementsByTagName("button").onclick = () => {
signIn("github")
console.log("overriding")
}
window.CMS.registerBackend("astro-auth")
window.CMS.init()
window.CMS.registerPreviewStyle("../src/styles/global.css")

Expand Down
10 changes: 8 additions & 2 deletions public/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
<title>Content Manager</title>
</head>
<body>

<button id="login" class="CMS_Login_button CMS_Button_root CMS_Button_contained-primary">Login</button>
<!-- Include the script that builds the page and powers Static CMS -->
<script src="https://unpkg.com/@staticcms/app@^4.0.0/dist/static-cms-app.js">
const { signIn } = await import("auth-astro/client")
document.querySelector(".CMS_Login_button").onclick = () => signIn("github")
</script>
<script type="module" src="/admin/config.js"></script>
<script type="module">
import { signIn } from "../../node_modules/auth-astro/client.ts"

document.querySelector("#login").onclick = () => signIn("github")

</script>
</body>
</html>

0 comments on commit c9fd46f

Please sign in to comment.