Skip to content

Commit

Permalink
Merge pull request #516 from w3bdesign/develop
Browse files Browse the repository at this point in the history
Featured project sorting
  • Loading branch information
w3bdesign authored Dec 8, 2024
2 parents 2d72cc6 + 9d022fd commit 43ab86e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
14 changes: 1 addition & 13 deletions src/app/prosjekter/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ export const metadata: Metadata = {
export default async function Prosjekter() {
const posts: Project[] = await client.fetch(projectsQuery);

const featuredProjects = posts.filter((project) => project.featured);
const nonFeaturedProjects = posts.filter((project) => !project.featured);

return (
<RootLayout>
<main
Expand All @@ -28,17 +25,8 @@ export default async function Prosjekter() {
>
<PageHeader>Prosjekter</PageHeader>
<div className="container mx-auto">
{featuredProjects.length > 0 && (
<div className="mb-12">
<div className="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-1 xl:grid-cols-2 gap-8">
{featuredProjects.map((project) => (
<ProsjektCard key={project.id} {...project} />
))}
</div>
</div>
)}
<div className="grid grid-cols-1 sm:grid-cols-1 md:grid-cols-1 xl:grid-cols-2 gap-8">
{nonFeaturedProjects.map((project) => (
{posts.map((project) => (
<ProsjektCard key={project.id} {...project} />
))}
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/lib/sanity/queries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { groq } from "next-sanity";

export const projectsQuery = groq`
*[_type == "project"]{
*[_type == "project"] | order(featureOrder asc) {
id,
name,
description,
Expand All @@ -18,7 +18,9 @@ export const projectsQuery = groq`
...,
_key,
},
"projectimage": projectimage.asset->url
"projectimage": projectimage.asset->url,
featured,
featureOrder
}
`;

Expand Down

0 comments on commit 43ab86e

Please sign in to comment.