Skip to content

Commit

Permalink
Joseglego/integration sanity (#43)
Browse files Browse the repository at this point in the history
* refactor: add .env file to .gitignore

* feat: add sanity integration

* feat: add sanity schema for navs

* fix: import formatting in page.tsx and sanity.ts

* chore(sanity): update sanity POC

* chore(codegen): include codegen

* chore(sanity): include markdown plugin

* chore(sanity): update POC wiht sanity + codegen

* chore(sanity): remove POC of page

* chore(sanity): define first schema

* chore(sanity): generating static pages

---------

Co-authored-by: Irwing Naranjo <[email protected]>
  • Loading branch information
joseglego and geekhadev committed Jun 1, 2024
1 parent fadda41 commit 68b9360
Show file tree
Hide file tree
Showing 41 changed files with 20,645 additions and 5,764 deletions.
5 changes: 5 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
NEXT_PUBLIC_POSTHOG_KEY=
NEXT_PUBLIC_POSTHOG_HOST=
NEXT_PUBLIC_POSTHOG_UI_HOST=

NEXT_PUBLIC_SANITY_PROJECT_ID=
NEXT_PUBLIC_SANITY_DATASET=

SANITY_API_READ_TOKEN=
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ yarn-error.log*
next-env.d.ts

# eslint
.eslintcache
.eslintcache
.env

.sanity
dist
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# # GQL / code-generation
src/api/**/*
src/**/*.generated.*
app/**/*.gener
38 changes: 38 additions & 0 deletions codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { CodegenConfig } from '@graphql-codegen/cli';
import defaultConfig from "./graphql.config";

const noTypeCheckingPlugin = {
add: {
content: [
"/* eslint-disable */",
"/* @ts-nocheck */",
"/* prettier-ignore */",
"/* This file is automatically generated. Please do not modify it manually. */",
],
},
};

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const config: CodegenConfig = {
...defaultConfig,
ignoreNoDocuments: true,
generates: {
"src/api/schema.gql": {
plugins: ["schema-ast"],
},
"src/api/types.ts": {
plugins: [
"typescript",
"typescript-operations",
"typescript-graphql-request",
noTypeCheckingPlugin,
],
config: {
avoidOptionals: true,
useTypeImports: true,
defaultScalarType: "unknown",
},
},
},
} satisfies CodegenConfig;
export default config;
14 changes: 14 additions & 0 deletions graphql.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { IGraphQLConfig } from "graphql-config";
import { loadEnvConfig } from "@next/env";

loadEnvConfig(process.cwd());

const projectId = process.env.NEXT_PUBLIC_SANITY_PROJECT_ID
const dataset = process.env.NEXT_PUBLIC_SANITY_DATASET

const config: IGraphQLConfig = {
schema: `https://${projectId}.api.sanity.io/v1/graphql/${dataset}/default`,
documents: ["src/**/*.gql"],
};

export default config;
Loading

0 comments on commit 68b9360

Please sign in to comment.