Skip to content

Commit

Permalink
feat(web): add initial configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mheob committed Aug 29, 2024
1 parent 5f59d10 commit 7f92f8e
Show file tree
Hide file tree
Showing 14 changed files with 931 additions and 101 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"**/turbo.json"
],
"words": [
"Aufzählungspunkte",
"astro",
"astrojs",
"Aufzählungspunkte",
"Blogautor",
"Blogpost",
"Blogposts",
Expand Down
26 changes: 21 additions & 5 deletions apps/studio/env.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
/* eslint-disable node/prefer-global/process */

import 'dotenv/config';

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

/**
* The Sanity Studio dataset to use.
* This is loaded from the `SANITY_API_DATASET` environment variable.
* If the environment variable is missing, an error will be thrown.
*/
export const dataset = assertValue(
process.env.SANITY_STUDIO_DATASET,
'Missing environment variable: SANITY_STUDIO_DATASET',
process.env.SANITY_API_DATASET,
'Missing environment variable: SANITY_API_DATASET',
);

/**
* The Sanity Studio project ID to use.
* This is loaded from the `SANITY_API_PROJECT_ID` environment variable.
* If the environment variable is missing, an error will be thrown.
*/
export const projectId = assertValue(
process.env.SANITY_STUDIO_PROJECT_ID,
'Missing environment variable: SANITY_STUDIO_PROJECT_ID',
process.env.SANITY_API_PROJECT_ID,
'Missing environment variable: SANITY_API_PROJECT_ID',
);

/**
* see https://www.sanity.io/docs/api-versioning for how versioning works
* The Sanity Studio API version to use.
* This is loaded from the `SANITY_API_VERSION` environment variable, or defaults to '2022-03-07'
* if the environment variable is missing.
*
* @see https://www.sanity.io/docs/api-versioning for how versioning works
*/
export const apiVersion = process.env.SANITY_API_VERSION ?? '2022-03-07';
7 changes: 1 addition & 6 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"name": "studio",
"version": "0.0.0",
"private": true,
"keywords": [
"sanity"
],
"license": "MIT",
"type": "module",
"main": "package.json",
"scripts": {
"build": "sanity build",
"deploy": "sanity deploy",
Expand All @@ -20,6 +14,7 @@
"@sanity/assist": "^3.0.6",
"@sanity/locale-de-de": "^1.1.10",
"@sanity/vision": "^3.55.0",
"@tsg-irlich-web/shared": "workspace:*",
"dotenv": "^16.4.5",
"dotenv-expand": "^11.0.6",
"react": "^18.3.1",
Expand Down
21 changes: 20 additions & 1 deletion apps/web/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
import react from '@astrojs/react';
import tailwind from '@astrojs/tailwind';
import vercel from '@astrojs/vercel/serverless';
import sanity from '@sanity/astro';
import { defineConfig } from 'astro/config';

import { apiVersion, dataset, projectId } from './src/env';

// https://astro.build/config
export default defineConfig({});
export default defineConfig({
adapter: vercel(),
integrations: [
tailwind(),
react(),
sanity({
apiVersion,
dataset,
projectId,
useCdn: true,
}),
],
output: 'server',
});
16 changes: 15 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"astro": "astro",
Expand All @@ -12,10 +12,24 @@
},
"dependencies": {
"@astrojs/check": "^0.9.3",
"@astrojs/react": "^3.6.2",
"@astrojs/tailwind": "^5.1.0",
"@astrojs/vercel": "^7.8.0",
"@sanity/astro": "^3.1.4",
"@sanity/client": "^6.21.3",
"@sanity/visual-editing": "^2.1.9",
"@tsg-irlich-web/shared": "workspace:*",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"astro": "^4.14.5",
"astro-eslint-parser": "^1.0.2",
"dotenv": "^16.4.5",
"eslint-plugin-astro": "^1.2.3",
"prettier-plugin-astro": "^0.14.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sanity": "^3.55.0",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.4"
}
}
37 changes: 37 additions & 0 deletions apps/web/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable node/prefer-global/process */

import 'dotenv/config';

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

/**
* The Sanity Studio dataset to use.
* This is loaded from the `SANITY_API_DATASET` environment variable.
* If the environment variable is missing, an error will be thrown.
*/
export const dataset = assertValue(
process.env.SANITY_API_DATASET,
'Missing environment variable: SANITY_API_DATASET',
);

/**
* The Sanity Studio project ID to use.
* This is loaded from the `SANITY_API_PROJECT_ID` environment variable.
* If the environment variable is missing, an error will be thrown.
*/
export const projectId = assertValue(
process.env.SANITY_API_PROJECT_ID,
'Missing environment variable: SANITY_API_PROJECT_ID',
);

/**
* The Sanity Studio API version to use.
* This is loaded from the `SANITY_API_VERSION` environment variable, or defaults to '2022-03-07'
* if the environment variable is missing.
*
* @see https://www.sanity.io/docs/api-versioning for how versioning works
*/
export const apiVersion = process.env.SANITY_API_VERSION ?? '2022-03-07';
6 changes: 5 additions & 1 deletion apps/web/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
</head>

<body>
<h1>Astro</h1>
<header>HEADER: TSG Irlich seit 1882</header>

<h1>CONTENT: TSG Irlich seit 1882</h1>

<header>FOOTER: TSG Irlich seit 1882</header>
</body>
</html>
8 changes: 8 additions & 0 deletions apps/web/tailwind.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
plugins: [],
theme: {
extend: {},
},
};
6 changes: 5 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "@mheob/tsconfig/astro"
"extends": "@mheob/tsconfig/astro",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "react"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "tsg-irlich",
"name": "@tsg-irlich-web/root",
"private": true,
"type": "module",
"workspaces": [
Expand Down Expand Up @@ -37,7 +37,7 @@
"turbo": "^2.0.14",
"typescript": "^5.5.4"
},
"packageManager": "pnpm@9.6.0+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e",
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1",
"engines": {
"node": "^20.0.0"
}
Expand Down
22 changes: 22 additions & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@tsg-irlich-web/shared",
"version": "1.0.0",
"description": "",
"keywords": [],
"license": "ISC",
"author": "",
"exports": {
"./*": "./src/*.ts"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"dotenv": "^16.4.5"
},
"devDependencies": {
"@mheob/tsconfig": "^2.2.1",
"@types/node": "^20.14.8",
"typescript": "^5.5.4"
}
}
37 changes: 37 additions & 0 deletions packages/shared/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable node/prefer-global/process */

import 'dotenv/config';

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

/**
* The Sanity Studio dataset to use.
* This is loaded from the `SANITY_API_DATASET` environment variable.
* If the environment variable is missing, an error will be thrown.
*/
export const dataset = assertValue(
process.env.SANITY_API_DATASET,
'Missing environment variable: SANITY_API_DATASET',
);

/**
* The Sanity Studio project ID to use.
* This is loaded from the `SANITY_API_PROJECT_ID` environment variable.
* If the environment variable is missing, an error will be thrown.
*/
export const projectId = assertValue(
process.env.SANITY_API_PROJECT_ID,
'Missing environment variable: SANITY_API_PROJECT_ID',
);

/**
* The Sanity Studio API version to use.
* This is loaded from the `SANITY_API_VERSION` environment variable, or defaults to '2022-03-07'
* if the environment variable is missing.
*
* @see https://www.sanity.io/docs/api-versioning for how versioning works
*/
export const apiVersion = process.env.SANITY_API_VERSION ?? '2022-03-07';
3 changes: 3 additions & 0 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@mheob/tsconfig/base"
}
Loading

0 comments on commit 7f92f8e

Please sign in to comment.