Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Featured projects #203

Merged
merged 4 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions src/app/prosjekter/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@ import Header from "@/components/Layout/Header.component";
import PageHeader from "@/components/UI/PageHeader.component";
import ProsjektCard from "@/components/Prosjekter/ProsjektCard.component";

import { projectsQuery } from "@/lib/sanity/queries";
import { client } from "@/lib/sanity/client";

import type { Project } from "@/types/sanity.types";
import { Metadata } from "next/types";
import type { Metadata } from "next/types";

export const metadata: Metadata = {
title: "Prosjekter - Dfweb",
description: "Daniel Fjeldstad | Frontend Web Utvikler | Portefølje",
};

const projectsQuery = `*[_type == "project"] | order(featured desc, featureOrder asc, _createdAt desc) {
id,
name,
description,
subdescription,
projectimage,
urlwww,
urlgithub,
featured,
featureOrder
}`;

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 (
<>
<Header />
Expand All @@ -25,10 +39,21 @@ export default async function Prosjekter() {
className="mt-32 bg-graybg"
>
<PageHeader>Prosjekter</PageHeader>
<div className="container mx-auto grid grid-cols-1 sm:grid-cols-1 md:grid-cols-1 xl:grid-cols-2 gap-8">
{posts?.map((project) => (
<ProsjektCard key={project.id} {...project} />
))}
<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) => (
<ProsjektCard key={project.id} {...project} />
))}
</div>
</div>
</main>
</>
Expand Down
Loading