Skip to content

Commit

Permalink
feat: add basic sanity client call
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc-resourcify committed Jul 7, 2023
1 parent db28722 commit 27188a5
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 5 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@mui/material": "^5.13.5",
"@sanity/client": "^6.1.4",
"@sanity/code-input": "^4.1.1",
"@sanity/document-internationalization": "^2.0.1",
"@sanity/icons": "^2.0.0",
"@sanity/image-url": "1",
"@sanity/types": "^3.0.0",
Expand All @@ -49,6 +50,7 @@
"react-icons": "^4.10.1",
"react-tippy": "^1.4.0",
"sanity": "^3.0.0",
"sanity-plugin-internationalized-array": "^1.7.0",
"sanity-plugin-media": "^2.2.1",
"styled-components": "^5.2.0",
"tailwind-merge": "^1.12.0"
Expand Down
2 changes: 1 addition & 1 deletion sanity/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createClient } from 'next-sanity';

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

export const client = createClient({
export const sanityClient = createClient({
apiVersion,
dataset,
projectId,
Expand Down
15 changes: 15 additions & 0 deletions src/pages/api/skills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NextApiRequest, NextApiResponse } from 'next';

import { skillQuery } from '@/queries/skills';

import { sanityClient } from '../../../sanity/lib/client';

import { Skill } from '@/types/Skill';

const skillsApi = async (req: NextApiRequest, res: NextApiResponse) => {
const skills: Skill[] = await sanityClient.fetch(skillQuery);

res.status(200).json(skills);
};

export default skillsApi;
17 changes: 17 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import Seo from '@/components/Seo';
* @see https://stackoverflow.com/questions/68103844/how-to-override-next-js-svg-module-declaration
*/
// import Vercel from '~/svg/Vercel.svg';
//
// const getData = async () => {
// const skills: Skill[] = await sanityClient.fetch(skillQuery);
//
// return {
// skills
// }
// }

export default function HomePage() {
return (
Expand All @@ -23,6 +31,15 @@ export default function HomePage() {
<main>
<section className='dark:bg-dark bg-white'>
<div className='layout relative flex min-h-screen flex-col items-center justify-center py-12 text-center'>
{/*{skills[0].name}*/}
{/*{*/}
{/* skills.map((skill) => (*/}
{/* <span key={skill.name}>*/}
{/* {skill.title}*/}
{/* </span>*/}
{/* ))*/}
{/*}*/}

{/*<Vercel className='text-5xl' />*/}
{/*<h1 className='mt-4'>*/}
{/* Next.js + Tailwind CSS + TypeScript Starter*/}
Expand Down
7 changes: 7 additions & 0 deletions src/queries/skills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { groq } from 'next-sanity';

export const skillQuery = groq`
*[_type == "skill"] {
name,
title,
}`;
57 changes: 53 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,18 @@
dependencies:
diff-match-patch "^1.0.4"

"@sanity/document-internationalization@^2.0.1":
version "2.0.1"
resolved "https://verdaccio.mein-recycling.de/@sanity%2fdocument-internationalization/-/document-internationalization-2.0.1.tgz#39e784e0995b4166ce76d33ea3e082f023845d32"
integrity sha512-pfLx7rfu2rfTn9xRm4hTpKGSK2HwE8oTA91CNfxWrRjvfgF/pgJ2nzTTEbLZ1FfIn/EEQ+MgQwrS2GqbE3uhfw==
dependencies:
"@sanity/icons" "^2.2.2"
"@sanity/incompatible-plugin" "^1.0.4"
"@sanity/ui" "^1.2.2"
"@sanity/uuid" "^3.0.1"
sanity-plugin-internationalized-array "^1.6.0"
sanity-plugin-utils "^1.6.2"

"@sanity/eventsource@5", "@sanity/eventsource@^5.0.0":
version "5.0.0"
resolved "https://verdaccio.mein-recycling.de/@sanity%2feventsource/-/eventsource-5.0.0.tgz#45410c8259e0bb80b4e308e1872846439590805a"
Expand Down Expand Up @@ -3848,7 +3860,7 @@
resolved "https://verdaccio.mein-recycling.de/@sanity%2ficons/-/icons-1.3.10.tgz#df934a94ae6669fe6b15515d800afb221cba0498"
integrity sha512-5wVG/vIiGuGrSmq+Bl3PY7XDgQrGv0fyHdJI64FSulnr2wH3NMqZ6C59UFxnrZ93sr7kOt0zQFoNv2lkPBi0Cg==

"@sanity/icons@^2.0.0", "@sanity/icons@^2.3.1", "@sanity/icons@^2.4.0":
"@sanity/icons@^2.0.0", "@sanity/icons@^2.2.2", "@sanity/icons@^2.3.1", "@sanity/icons@^2.4.0":
version "2.4.1"
resolved "https://verdaccio.mein-recycling.de/@sanity%2ficons/-/icons-2.4.1.tgz#34ce2c5b58f53c7369ff926b651ea57c4e3c0a8c"
integrity sha512-/yxcIT0k1RxStI/pP/oHM44fHI6Oxiygf0jPcdV06Ce0xfFo+51UEqJSfE8hQ3fh+uFkat8ZZObZjq5v1ceJzw==
Expand Down Expand Up @@ -3890,6 +3902,16 @@
"@sanity/icons" "^1.3"
react-copy-to-clipboard "^5.1.0"

"@sanity/language-filter@^3.1.2":
version "3.1.2"
resolved "https://verdaccio.mein-recycling.de/@sanity%2flanguage-filter/-/language-filter-3.1.2.tgz#8ac7507f667a1182dd135238b39cbfa0fa71c23b"
integrity sha512-Z4yILQoRqVbhnIDE6WGAQx/6gVvcwk75y1wVXu0drjKwRFTouVLaMQyHjsEWbMl+wQz5QFbVMpL9WEKB9z3p2A==
dependencies:
"@sanity/icons" "^2.0.0"
"@sanity/incompatible-plugin" "^1.0.4"
"@sanity/ui" "^1.0.0"
"@sanity/util" "^3.0.0"

"@sanity/logos@^2.0.2":
version "2.1.2"
resolved "https://verdaccio.mein-recycling.de/@sanity%2flogos/-/logos-2.1.2.tgz#0568c315cd1cfa292deebf61db1582a12474648f"
Expand Down Expand Up @@ -3972,7 +3994,7 @@
"@sanity/client" "^6.1.5"
"@types/react" "^18.0.25"

"@sanity/ui@^1.0.0", "@sanity/ui@^1.7.0":
"@sanity/ui@^1.0.0", "@sanity/ui@^1.2.2", "@sanity/ui@^1.7.0":
version "1.7.1"
resolved "https://verdaccio.mein-recycling.de/@sanity%2fui/-/ui-1.7.1.tgz#7656bd6da97a9b15b5e84b49e82abdb36c71fe6a"
integrity sha512-N8X/4ZVVvSs4YmfJrfohWX1YtFq8ASnbIADw1/Ak9qQgBzJ7aazILfzxfmqy8HH5KcmXTpXFrZ5WKBIp4x3mWg==
Expand All @@ -3996,7 +4018,7 @@
framer-motion "^10.12.16"
react-refractor "^2.1.7"

"@sanity/util@3.14.1":
"@sanity/util@3.14.1", "@sanity/util@^3.0.0":
version "3.14.1"
resolved "https://verdaccio.mein-recycling.de/@sanity%2futil/-/util-3.14.1.tgz#cbeda86ee0045e1f0095ee50a6dc1fa5b00313e1"
integrity sha512-kSO+RodwjggVYMbue4SGoqlAjBW85SHJ9svXthhvSRzGiylNNXNEJy2hkRwuiyBF60o3Rj2MNr16C8Wxt0NxXw==
Expand Down Expand Up @@ -14240,6 +14262,19 @@ sanity-diff-patch@^1.0.9:
dependencies:
diff-match-patch "^1.0.5"

sanity-plugin-internationalized-array@^1.6.0, sanity-plugin-internationalized-array@^1.7.0:
version "1.7.0"
resolved "https://verdaccio.mein-recycling.de/sanity-plugin-internationalized-array/-/sanity-plugin-internationalized-array-1.7.0.tgz#f4c503a238b20d2ecd7ca4ec8b19f6827d1b24a8"
integrity sha512-pVcot//jK/e6Fje2igum4iqeA6dfR2ok+Z72KAlwZqHXr0/EmzpvW5TnQA01xEeSu36RMOsCOQ4ph16bNsJ8Gw==
dependencies:
"@sanity/icons" "^2.2.2"
"@sanity/incompatible-plugin" "^1.0.4"
"@sanity/language-filter" "^3.1.2"
"@sanity/ui" "^1.2.2"
fast-deep-equal "^3.1.3"
lodash.get "^4.4.2"
suspend-react "^0.0.8"

sanity-plugin-media@^2.2.1:
version "2.2.1"
resolved "https://verdaccio.mein-recycling.de/sanity-plugin-media/-/sanity-plugin-media-2.2.1.tgz#94c2f4c6e10d94dd2b27bdc45dcd02d04b613324"
Expand Down Expand Up @@ -14269,6 +14304,15 @@ sanity-plugin-media@^2.2.1:
rxjs "^7.0.0"
zod "^3.21.4"

sanity-plugin-utils@^1.6.2:
version "1.6.2"
resolved "https://verdaccio.mein-recycling.de/sanity-plugin-utils/-/sanity-plugin-utils-1.6.2.tgz#f9770cc7beffe825b5f42b73964167e1cf5b392f"
integrity sha512-zn4sKLaLG5ZcibPNB8RfTjU32sear2XIHPxIoIWJCHXO3yD+JEq+/MvkwW7CnfdEcZeXPfb5DEx1CGjIQwO3Iw==
dependencies:
"@sanity/icons" "^2.2.2"
"@sanity/incompatible-plugin" "^1.0.4"
styled-components "^5.3.6"

sanity@^3.0.0:
version "3.14.1"
resolved "https://verdaccio.mein-recycling.de/sanity/-/sanity-3.14.1.tgz#cd9ce6c10c3382653861761d8faf80b69f9096f4"
Expand Down Expand Up @@ -15028,7 +15072,7 @@ style-mod@^4.0.0:
resolved "https://verdaccio.mein-recycling.de/style-mod/-/style-mod-4.0.3.tgz#136c4abc905f82a866a18b39df4dc08ec762b1ad"
integrity sha512-78Jv8kYJdjbvRwwijtCevYADfsI0lGzYJe4mMFdceO8l75DFFDoqBhR1jVDicDRRaX4//g1u9wKeo+ztc2h1Rw==

styled-components@^5.2.0:
styled-components@^5.2.0, styled-components@^5.3.6:
version "5.3.11"
resolved "https://verdaccio.mein-recycling.de/styled-components/-/styled-components-5.3.11.tgz#9fda7bf1108e39bf3f3e612fcc18170dedcd57a8"
integrity sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==
Expand Down Expand Up @@ -15108,6 +15152,11 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

suspend-react@^0.0.8:
version "0.0.8"
resolved "https://verdaccio.mein-recycling.de/suspend-react/-/suspend-react-0.0.8.tgz#b0740c1386b4eb652f17affe4339915ee268bd31"
integrity sha512-ZC3r8Hu1y0dIThzsGw0RLZplnX9yXwfItcvaIzJc2VQVi8TGyGDlu92syMB5ulybfvGLHAI5Ghzlk23UBPF8xg==

svg-parser@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/svg-parser/-/svg-parser-2.0.4.tgz#fdc2e29e13951736140b76cb122c8ee6630eb6b5"
Expand Down

0 comments on commit 27188a5

Please sign in to comment.