Skip to content

Commit

Permalink
feat: initial commit of Sanity and Next
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiewarb committed May 11, 2024
0 parents commit 076a8e9
Show file tree
Hide file tree
Showing 289 changed files with 19,286 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# editorconfig.org
root = true

[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

Empty file added .github/apps.sanity.env
Empty file.
Empty file added .github/apps.web.env
Empty file.
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: ci

on:
push:
branches:
- main
pull_request:
branches:
- '**'

jobs:
ci:
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, '[ci skip]')"

strategy:
matrix:
os: [ubuntu-latest]
node: [18]

steps:
- name: Checkout 🛎
uses: actions/checkout@master

- name: Setup pnpm 🦾
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup node env 🏗
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: 'pnpm'

- name: Setup Next application 🥾
run: |
cp .github/apps.web.env apps/web/.env
cp .github/apps.sanity.env apps/sanity/.env
- name: Install root + src dependencies 👨🏻‍💻
run: pnpm install

- name: Run linters 👀
run: |
pnpm --dir apps/web lint
pnpm --dir apps/sanity lint
- name: Run type checking 📚
run: |
pnpm --dir apps/web typecheck
pnpm --dir apps/sanity typecheck
#- name: Run tests 🧪
# run: pnpm test

# Builds are already handled by the Vercel integration, so no need to run this here
#- name: Build app 🖥
# run: pnpm --dir apps/web build

#- name: Build app 🖥
# run: pnpm --dir apps/sanity build
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Nuxt dev/build outputs
.output
.data
.next
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example

.eslintcache

# Sanity
apps/sanity/exports
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm commitlint --edit ${1}
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
10 changes: 10 additions & 0 deletions .syncpackrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"versionGroups": [
{
"label": "Use workspace protocol when using local packages",
"dependencies": ["$LOCAL"],
"dependencyTypes": ["local"],
"isIgnored": "true",
}
]
}
15 changes: 15 additions & 0 deletions .vscode/postcss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 1.1,
"atDirectives": [
{
"name": "@mixin",
"description": "Use the `@mixin` directive to insert mixins into your CSS.",
"references": [
{
"name": "PostCSS Mixins",
"url": "https://github.com/postcss/postcss-mixins"
}
]
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"css.customData": [".vscode/tailwind.json", ".vscode/postcss.json"]
}
55 changes: 55 additions & 0 deletions .vscode/tailwind.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"version": 1.1,
"atDirectives": [
{
"name": "@tailwind",
"description": "Use the `@tailwind` directive to insert Tailwind's `base`, `components`, `utilities` and `screens` styles into your CSS.",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#tailwind"
}
]
},
{
"name": "@apply",
"description": "Use the `@apply` directive to inline any existing utility classes into your own custom CSS. This is useful when you find a common utility pattern in your HTML that you’d like to extract to a new component.",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#apply"
}
]
},
{
"name": "@responsive",
"description": "You can generate responsive variants of your own classes by wrapping their definitions in the `@responsive` directive:\n```css\n@responsive {\n .alert {\n background-color: #E53E3E;\n }\n}\n```\n",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#responsive"
}
]
},
{
"name": "@screen",
"description": "The `@screen` directive allows you to create media queries that reference your breakpoints by **name** instead of duplicating their values in your own CSS:\n```css\n@screen sm {\n /* ... */\n}\n```\n…gets transformed into this:\n```css\n@media (min-width: 640px) {\n /* ... */\n}\n```\n",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#screen"
}
]
},
{
"name": "@variants",
"description": "Generate `hover`, `focus`, `active` and other **variants** of your own utilities by wrapping their definitions in the `@variants` directive:\n```css\n@variants hover, focus {\n .btn-brand {\n background-color: #3182CE;\n }\n}\n```\n",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#variants"
}
]
}
]
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# BirdLife Datazone Monorepo

A monorepo for BirdLife's Datazone, powered by [Next.js](https://nextjs.org/) and [SanityCMS](https://www.sanity.io/).

The repo has two apps in it that can be deployed separately: `apps/web` and `apps/sanity`

These apps are powered by workspace packages that are shared between the apps. These are all available at `packages/...`

pnpm manages dependencies automatically for all apps and packages, maintaining a central `pnpm-lock.yaml` file, and symlinking node_modules into their respective directories for use.

## Documentation

For an overview of the repository, development setup instructions, and general feature documentation, [please see the docs directory](./docs/0.Start-Here.md)
15 changes: 15 additions & 0 deletions apps/sanity/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# When adding a new key to .env, add it to this file as well to keep track of available options.
# If a variable has a default value that IS NOT SENSITIVE/PRIVATE, then also add it here for ease.
# NEVER add values to sensitive/secret keys to this file, leave them blank and add the value only to .env.

SANITY_STUDIO_SANITY_PROJECT_ID=6ibvd6r4
SANITY_STUDIO_SANITY_API_VERSION=2024-04-18
SANITY_STUDIO_SANITY_DATASET=development

SANITY_STUDIO_SANITY_DATASET_SHOW_ALL=true

SANITY_STUDIO_PREVIEW_DOMAIN=http://localhost:3000
SANITY_STUDIO_SANITY_PROJECT_TITLE="DataZone"

# Key must match SANITY_STUDIO_SECRET_KEY in apps/web/.env
SANITY_STUDIO_SECRET_KEY=
3 changes: 3 additions & 0 deletions apps/sanity/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@sanity/eslint-config-studio"
}
29 changes: 29 additions & 0 deletions apps/sanity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Dependencies
/node_modules
/.pnp
.pnp.js

# Compiled Sanity Studio
/dist

# Temporary Sanity runtime, generated by the CLI on every dev server start
/.sanity

# Logs
/logs
*.log

# Coverage directory used by testing tools
/coverage

# Misc
.DS_Store
*.pem

# Typescript
*.tsbuildinfo

# Dotenv and similar local-only files
*.local
7 changes: 7 additions & 0 deletions apps/sanity/.lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
'*.{ts,tsx}': [
'echo "lintstaged paused"'
// 'eslint --fix',
// () => 'pnpm typecheck', // Have to run typecheck on all files via a function - can't check just staged files
],
};
9 changes: 9 additions & 0 deletions apps/sanity/README.md
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)
50 changes: 50 additions & 0 deletions apps/sanity/config/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* As this file is reused in several other files, try to keep it lean and small.
* Importing other npm packages here could lead to needlessly increasing the client bundle size,
* or end up in a server-only function that don't need it.
*/

export type Options = typeof options;

export const options = {
dataset: assertValue(
process.env.SANITY_STUDIO_SANITY_DATASET,
'Missing environment variable: SANITY_STUDIO_SANITY_DATASET',
),

projectId: assertValue(
process.env.SANITY_STUDIO_SANITY_PROJECT_ID,
'Missing environment variable: SANITY_STUDIO_SANITY_PROJECT_ID',
),

// see https://www.sanity.io/docs/api-versioning for how versioning works
apiVersion: process.env.SANITY_STUDIO_SANITY_API_VERSION || '2024-04-18',

title: process.env.SANITY_STUDIO_SANITY_PROJECT_TITLE || 'DataZone',

preview: {
// The domain on which we will preview content
domain: assertValue(
process.env.SANITY_STUDIO_PREVIEW_DOMAIN,
'Missing environment variable: SANITY_STUDIO_PREVIEW_DOMAIN',
),

// The route to enable draft mode. See: https://github.com/sanity-io/visual-editing/tree/main/packages/preview-url-secret#sanitypreview-url-secret
draftModeRoute: '/api/sanity/draft',

// This is the document id used for the preview secret that's stored in your dataset. It must have a dot ('.') in it to make it private.
// The secret protects against unauthorized access to your draft content and have a lifetime of 60 minutes, to protect against bruteforcing.
secretId: 'preview.secret' satisfies `${string}.${string}`,
},

// For use when revalidating caches in the web app - secret must match in Sanity app and in Web app
revalidateSecret: process.env.SANITY_STUDIO_SANITY_REVALIDATE_SECRET,
}

function assertValue<Value>(value: Value | undefined, errorMessage: string): Value {
if (value === undefined) {
throw new Error(errorMessage);
}

return value;
}
1 change: 1 addition & 0 deletions apps/sanity/declaration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '*.css';
53 changes: 53 additions & 0 deletions apps/sanity/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "datazone",
"private": true,
"version": "1.0.0",
"main": "package.json",
"license": "UNLICENSED",
"scripts": {
"dev": "sanity dev",
"start": "sanity start",
"build": "sanity build",
"deploy": "sanity deploy",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"typecheck": "echo 'Typecheck not yet implemented'"
},
"keywords": [
"sanity"
],
"dependencies": {
"@pkg/config": "workspace:*",
"@pkg/logger": "workspace:*",
"@pkg/modular-content-blocks": "workspace:*",
"@pkg/sanity-studio": "workspace:*",
"@pkg/utilities": "workspace:*",
"@sanity/assist": "^3.0.3",
"@sanity/icons": "^2.11.7",
"@sanity/image-url": "^1.0.2",
"@sanity/ui": "^2.1.4",
"@sanity/vision": "^3.38.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"sanity": "^3.38.0",
"sanity-plugin-asset-source-unsplash": "^3.0.1",
"sanity-plugin-documents-pane": "^2.3.0",
"sanity-plugin-media": "^2.2.5",
"sanity-plugin-note-field": "^2.0.2",
"styled-components": "^6.1.8"
},
"devDependencies": {
"@sanity/eslint-config-studio": "^4.0.0",
"@types/react": "^18.0.25",
"eslint": "^8.6.0",
"prettier": "^3.0.2",
"typescript": "^5.1.6"
},
"prettier": {
"semi": false,
"printWidth": 100,
"bracketSpacing": false,
"singleQuote": true
}
}
9 changes: 9 additions & 0 deletions apps/sanity/sanity.cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineCliConfig } from 'sanity/cli';
import { options } from './config/options';

export default defineCliConfig({
api: {
projectId: options.projectId,
dataset: options.dataset,
}
})
Loading

0 comments on commit 076a8e9

Please sign in to comment.