-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added new example * docs: added new sections in readme
- Loading branch information
Showing
33 changed files
with
11,820 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
dist | ||
dist | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SANITY_DATASET="" | ||
SANITY_PROJECT_ID="" | ||
SANITY_API_TOKEN="" | ||
GITHUB_CLIENT_ID="" | ||
GITHUB_CLIENT_SECRET="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file. | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"packages": ["studio"], | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "full-example", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"@sanity/client": "^2.8.0", | ||
"next": "10.1.3", | ||
"next-auth": "^3.17.2", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.41", | ||
"@types/react": "^17.0.3", | ||
"lerna": "^3.22.1", | ||
"typescript": "^4.2.4" | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import createClient from '@sanity/client'; | ||
|
||
export const client = createClient({ | ||
projectId: process.env.SANITY_PROJECT_ID, | ||
dataset: process.env.SANITY_DATASET, | ||
token: process.env.SANITY_API_TOKEN, | ||
useCdn: process.env.NODE_ENV === 'production' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { FC } from 'react'; | ||
import { AppProps } from 'next/app'; | ||
import { Provider } from 'next-auth/client'; | ||
|
||
const MyApp: FC<AppProps> = ({ Component, pageProps }) => ( | ||
<Provider session={pageProps.session}> | ||
<Component {...pageProps} /> | ||
</Provider> | ||
); | ||
|
||
export default MyApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import NextAuth, { NextAuthOptions } from 'next-auth'; | ||
import Providers from 'next-auth/providers'; | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import { SanityAdapter } from 'next-auth-sanity'; | ||
import { client } from '../../../libs/sanity'; | ||
|
||
const options: NextAuthOptions = { | ||
providers: [ | ||
Providers.GitHub({ | ||
clientId: process.env.GITHUB_CLIENT_ID, | ||
clientSecret: process.env.GITHUB_CLIENT_SECRET | ||
}) | ||
], | ||
session: { | ||
jwt: true | ||
}, | ||
adapter: SanityAdapter({ client }) | ||
}; | ||
|
||
export default (req: NextApiRequest, res: NextApiResponse) => | ||
NextAuth(req, res, options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { FC } from 'react'; | ||
import { useSession, signIn, signOut } from 'next-auth/client'; | ||
|
||
const Home: FC = () => { | ||
const [session, loading] = useSession(); | ||
|
||
if (loading) return <p>Loading...</p>; | ||
|
||
if (session) { | ||
return ( | ||
<div> | ||
<p>User: {session.user.name}</p> | ||
<button onClick={() => signOut({ redirect: false })}>Sign Out</button> | ||
</div> | ||
); | ||
} | ||
|
||
return <button onClick={() => signIn('github')}>Sign In</button>; | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Sanity Clean Content Studio | ||
|
||
Congratulations, you have now installed the Sanity Content Studio, an open source real-time content editing environment connected to the Sanity backend. | ||
|
||
Now you can do the following things: | ||
|
||
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme) | ||
- [Join the community Slack](https://slack.sanity.io/?utm_source=readme) | ||
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"#": "Used by Sanity to keep track of configuration file checksums, do not delete or modify!", | ||
"@sanity/default-layout": "bb034f391ba508a6ca8cd971967cbedeb131c4d19b17b28a0895f32db5d568ea", | ||
"@sanity/default-login": "6fb6d3800aa71346e1b84d95bbcaa287879456f2922372bb0294e30b968cd37f", | ||
"@sanity/form-builder": "b38478227ba5e22c91981da4b53436df22e48ff25238a55a973ed620be5068aa", | ||
"@sanity/data-aspects": "d199e2c199b3e26cd28b68dc84d7fc01c9186bf5089580f2e2446994d36b3cb6" | ||
} |
3 changes: 3 additions & 0 deletions
3
examples/full-example/studio/config/@sanity/data-aspects.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"listOptions": {} | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/full-example/studio/config/@sanity/default-layout.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"toolSwitcher": { | ||
"order": [], | ||
"hidden": [] | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/full-example/studio/config/@sanity/default-login.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"providers": { | ||
"mode": "append", | ||
"redirectOnSingle": false, | ||
"entries": [] | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
examples/full-example/studio/config/@sanity/form-builder.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"images": { | ||
"directUploads": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "nextauthsanity", | ||
"private": true, | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "package.json", | ||
"author": "Federico Minaya <[email protected]>", | ||
"license": "UNLICENSED", | ||
"scripts": { | ||
"start": "sanity start", | ||
"build": "sanity build" | ||
}, | ||
"keywords": [ | ||
"sanity" | ||
], | ||
"dependencies": { | ||
"@sanity/base": "^2.8.1", | ||
"@sanity/components": "^2.2.6", | ||
"@sanity/core": "^2.8.0", | ||
"@sanity/default-layout": "^2.8.1", | ||
"@sanity/default-login": "^2.8.0", | ||
"@sanity/desk-tool": "^2.8.1", | ||
"@sanity/vision": "^2.8.0", | ||
"prop-types": "^15.7", | ||
"react": "^17.0", | ||
"react-dom": "^17.0" | ||
}, | ||
"devDependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
User-specific packages can be placed here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"root": true, | ||
"project": { | ||
"name": "next-auth-sanity" | ||
}, | ||
"api": { | ||
"projectId": "placeholder", | ||
"dataset": "placeholder" | ||
}, | ||
"plugins": [ | ||
"@sanity/base", | ||
"@sanity/components", | ||
"@sanity/default-layout", | ||
"@sanity/default-login", | ||
"@sanity/desk-tool" | ||
], | ||
"env": { | ||
"development": { | ||
"plugins": ["@sanity/vision"] | ||
} | ||
}, | ||
"parts": [ | ||
{ | ||
"name": "part:@sanity/base/schema", | ||
"path": "./schemas/schema" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Document } from './schemaTypes'; | ||
|
||
export default <Document>{ | ||
name: 'account', | ||
title: 'Account', | ||
type: 'document', | ||
fields: [ | ||
{ | ||
name: 'providerType', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'providerId', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'providerAccountId', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'refreshToken', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'accessToken', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'accessTokenExpires', | ||
type: 'string' | ||
}, | ||
{ | ||
name: 'user', | ||
title: 'User', | ||
type: 'reference', | ||
to: { type: 'user' } | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// First, we must import the schema creator | ||
import createSchema from 'part:@sanity/base/schema-creator'; | ||
|
||
// Then import schema types from any plugins that might expose them | ||
import schemaTypes from 'all:part:@sanity/base/schema-type'; | ||
import user from './user'; | ||
import account from './account'; | ||
|
||
// Then we give our schema to the builder and provide the result to Sanity | ||
export default createSchema({ | ||
// We name our schema | ||
name: 'default', | ||
// Then proceed to concatenate our document type | ||
// to the ones provided by any plugins that are installed | ||
types: schemaTypes.concat([ | ||
/* Your types here! */ | ||
user, | ||
account | ||
]) | ||
}); |
Oops, something went wrong.