generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d5e2ae
commit c576c14
Showing
11 changed files
with
221 additions
and
73 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,10 +1,11 @@ | ||
import { type SchemaTypeDefinition } from 'sanity'; | ||
|
||
import job from '../src/schemas/job'; | ||
import school from '../src/schemas/school'; | ||
import shortText from '../src/schemas/shortText'; | ||
import skill from '../src/schemas/skill'; | ||
import skillIcon from '../src/schemas/skillIcon'; | ||
|
||
export const schema: { types: SchemaTypeDefinition[] } = { | ||
types: [job, shortText, skill, skillIcon], | ||
types: [job, school, shortText, skill, skillIcon], | ||
}; |
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
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,15 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
import { schoolsQuery } from '@/queries/schools'; | ||
|
||
import { sanityClient } from '../../../sanity/lib/client'; | ||
|
||
import { School } from '@/types/School'; | ||
|
||
const schoolsApi = async (req: NextApiRequest, res: NextApiResponse) => { | ||
const schools: School[] = await sanityClient.fetch(schoolsQuery); | ||
|
||
res.status(200).json(schools); | ||
}; | ||
|
||
export default schoolsApi; |
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,16 @@ | ||
import { groq } from 'next-sanity'; | ||
|
||
export const schoolsQuery = groq` | ||
*[_type == "school"] | order(endYear desc) { | ||
_id, | ||
name, | ||
schoolName, | ||
"schoolIcon": schoolIcon.asset->url, | ||
"flagUrl": countryFlag.asset->url, | ||
degreeName, | ||
degreeUrl, | ||
grade, | ||
startYear, | ||
endYear, | ||
description, | ||
}`; |
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,69 @@ | ||
import { defineField, defineType } from 'sanity'; | ||
|
||
export default defineType({ | ||
name: 'school', | ||
title: 'School', | ||
type: 'document', | ||
fields: [ | ||
defineField({ | ||
name: 'name', | ||
title: 'Name', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'schoolName', | ||
title: 'School Name', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'schoolIcon', | ||
title: 'School Icon', | ||
type: 'image', | ||
}), | ||
defineField({ | ||
name: 'countryFlag', | ||
title: 'Country Flag', | ||
type: 'image', | ||
}), | ||
defineField({ | ||
name: 'degreeName', | ||
title: 'Degree Name', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'degreeUrl', | ||
title: 'Degree Url', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'grade', | ||
title: 'Grade', | ||
type: 'string', | ||
}), | ||
defineField({ | ||
name: 'startYear', | ||
title: 'Start Year', | ||
type: 'number', | ||
initialValue: new Date().getFullYear() - 5, | ||
}), | ||
defineField({ | ||
name: 'endYear', | ||
title: 'End Year', | ||
type: 'number', | ||
initialValue: new Date().getFullYear() - 3, | ||
}), | ||
defineField({ | ||
name: 'description', | ||
title: 'Description', | ||
type: 'array', | ||
of: [{ type: 'block' }], | ||
}), | ||
], | ||
orderings: [ | ||
{ | ||
title: 'Most Recent', | ||
name: 'schoolDateDesc', | ||
by: [{ field: 'endYear', direction: 'desc' }], | ||
}, | ||
], | ||
}); |
Oops, something went wrong.