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

Commit

Permalink
Playing around with decap and Auth.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bradfordbarr committed Sep 18, 2024
1 parent 7db15dc commit c24f252
Show file tree
Hide file tree
Showing 9 changed files with 610 additions and 572 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pnpm-debug.log*
# environment variables
.env
.env.production
.env.local

# macOS-specific files
.DS_Store
Expand Down
21 changes: 10 additions & 11 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
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 { 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 node from "@astrojs/node"
import auth from "auth-astro"

// https://astro.build/config
export default defineConfig({
site: "https://example.com",
output: "hybrid",
integrations: [mdx(), sitemap(), tailwind(), react(), auth()],
adapter: node({
mode: "standalone"
})
});
mode: "standalone",
}),
})
2 changes: 2 additions & 0 deletions auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import GitHub from "@auth/core/providers/github"
import { defineConfig } from "auth-astro"

export default defineConfig({
debug: true,
injectEndpoints: false,
providers: [
GitHub({
clientId: import.meta.env.GITHUB_CLIENT_ID,
Expand Down
1,073 changes: 551 additions & 522 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@staticcms/proxy-server": "^4.0.4",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"astro": "^4.3.6",
"astro": "^4.15.7",
"auth-astro": "^4.1.2",
"date-fns": "^3.6.0",
"firebase": "^9.23.0",
Expand Down
36 changes: 24 additions & 12 deletions public/admin/config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
backend:
name: github
repo: brown-ccv/mmp
base_url: /
base_url: "http://localhost:4321"
auth_endpoint: /api/auth
site_domain: localhost
media_folder: public/images
media_library:
max_file_size: 734003200
name: uploadcare
config:
max_file_size: 734003200
i18n:
structure: multiple_folders
locales: [ en, es, pt ]
locales: [en, es, pt]
# The locale to be used for fields validation and as a baseline for the entry.
default_locale: en
collections:
Expand Down Expand Up @@ -41,7 +45,7 @@ collections:
- name: type
label: Staff Type
widget: select
options: [ 'Leadership', 'Advisors', 'Supporting Staff' ]
options: ["Leadership", "Advisors", "Supporting Staff"]
- name: name
label: Name
widget: string
Expand Down Expand Up @@ -71,7 +75,7 @@ collections:
i18n: duplicate
label: Email
widget: string
pattern: [ '.+@.+\..+', 'Email must follow standard guidelines' ]
pattern: ['.+@.+\..+', "Email must follow standard guidelines"]
- name: startDate
i18n: duplicate
label: Year Started Contributions
Expand All @@ -92,12 +96,12 @@ collections:
media_folder: public/pubs
create: true
identifier_field: citation
slug: '{{fields.classification}}-{{fields.pubDate}}_{{fields.author}}'
slug: "{{fields.classification}}-{{fields.pubDate}}_{{fields.author}}"
fields:
- name: classification
label: Classification
widget: select
options: [ 'Book', 'Chapter', 'Article', 'Dissertation' ]
options: ["Book", "Chapter", "Article", "Dissertation"]
- name: author
label: Author(s)
widget: text
Expand Down Expand Up @@ -138,7 +142,8 @@ collections:
- name: cat
label: Category
widget: select
options: [ 'Study Design', 'Questionnaire', 'Changes to Questionnaire', 'Codebook', 'Appendices' ]
options:
["Study Design", "Questionnaire", "Changes to Questionnaire", "Codebook", "Appendices"]
- name: title
label: Title
widget: string
Expand All @@ -150,15 +155,22 @@ collections:
label: Field Season
condition:
field: cat
value: 'Questionnaire'
value: "Questionnaire"
required: false
- name: codebookType
label: Codebook Category
condition:
field: cat
value: 'Codebook'
value: "Codebook"
widget: select
options: [ 'MMP Core', 'Community Level Supplementary', 'State Level Supplementary', 'National Level Supplementary', 'MSA Level Supplementary' ]
options:
[
"MMP Core",
"Community Level Supplementary",
"State Level Supplementary",
"National Level Supplementary",
"MSA Level Supplementary",
]
- name: archivo
i18n: duplicate
required: false
Expand Down Expand Up @@ -194,4 +206,4 @@ collections:
widget: text
- name: body
label: Post
widget: markdown
widget: markdown
33 changes: 14 additions & 19 deletions public/admin/index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/@staticcms/app@^4.0.0/dist/main.css" />
<link href="/admin/config.yml" type="text/yaml" rel="cms-config-url" />

<title>Content Manager</title>
</head>
<body>
<!-- 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>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="robots" content="noindex" />
<link href="/admin/config.yml" type="text/yaml" rel="cms-config-url" />
<title>Content Manager</title>
</head>
<body>
<script src="https://unpkg.com/decap-cms@^3.1.2/dist/decap-cms.js"></script>
<script type="module" src="/admin/config.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions src/pages/api/[...auth].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AstroAuth } from "auth-astro/server"

export const prerender = false

export const { GET, POST } = AstroAuth()
9 changes: 2 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"strictNullChecks": true,
"jsx": "react-jsx",
"jsxImportSource": "react"
}
}
"extends": "astro/tsconfigs/strict"
}

0 comments on commit c24f252

Please sign in to comment.