Skip to content

Commit

Permalink
🎨 clean queries + minor styling update to cards
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianNymark committed Dec 6, 2023
1 parent 909fab2 commit d819e73
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ export const ArticleCard = ({
>
<VStack justify="space-between" className="min-h-full relative">
<Box paddingBlock="0 5">
<Heading className="inner-shiny" size={main ? "xlarge" : "medium"}>
<span className="shiny">{title}</span>
</Heading>
<Box paddingBlock="0 2">
<Heading
className="inner-shiny"
size={main ? "xlarge" : "medium"}
>
<span className="shiny">{title}</span>
</Heading>
</Box>

<BodyLong size={main ? "large" : "small"}>
{main ? trunc(content, 770) : trunc(content, 100)}
{main ? trunc(content, 770) : trunc(content, 200)}
</BodyLong>
</Box>
<HStack gap="2">
Expand Down
36 changes: 32 additions & 4 deletions aksel.nav.no/website/components/layout/god-praksis-page/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ import { groq } from "next-sanity";
export const heroNavQuery = groq`"heroNav": *[_type == "gp.tema"]{
title,
"slug": slug.current,
"hasRefs": count(*[_type=="aksel_artikkel" && (^._id in undertema[]->tema._ref)]) > 0
"hasRefs": count(*[_type=="aksel_artikkel"
&& (^._id in undertema[]->tema._ref)]) > 0
}
`;

export const innholdstypeQuery = groq`"innholdstype": *[_type == "gp.innholdstype"]{
...,
"hasRefs": count(*[_type=="aksel_artikkel" && ^._id == innholdstype._ref]) > 0
"hasRefs": count(*[_type=="aksel_artikkel"
&& ^._id == innholdstype._ref]) > 0
}`;

export const chipDataQuery = groq`
"chipData": *[_type == "gp.tema.undertema"] {
title,
"types": *[_type== "gp.innholdstype"] {
title,
"count": count(*[_type == "aksel_artikkel" && (^._id == innholdstype._ref ) && (^.^._id in undertema[]._ref)])
"count": count(*[_type == "aksel_artikkel"
&& (^._id == innholdstype._ref ) && (^.^._id in undertema[]._ref)])
}
}`;

Expand All @@ -28,10 +31,35 @@ export const chipDataFrontpageQuery = groq`
}`;

export const articlesQuery = groq`
"articles": *[_type == "aksel_artikkel" && defined(undertema)] | order(publishedAt desc)[0...9]{
"articles": *[_type == "aksel_artikkel"
&& defined(undertema)]
| order(publishedAt desc)[0...9]{
heading,
ingress ,
"undertema": undertema[]->title,
"innholdstype": innholdstype->title,
"slug": slug.current
}`;

export const firstArticlesQuery = groq`
"articles": *[_type == "aksel_artikkel"
&& $slug in undertema[]->tema->slug.current][0...9]
| order(publishedAt desc) {
heading,
ingress ,
"undertema": undertema[]->title,
"innholdstype": innholdstype->title,
"slug": slug.current
}`;

export const temaQuery = groq`
"tema": *[_type == "gp.tema" && slug.current == $slug][0]{
...,
"slug": slug.current,
"undertema": *[_type == "gp.tema.undertema"
&& tema->slug.current == $slug
&& count(*[_type == "aksel_artikkel" && references(^._id)]) > 0]{
title,
description
}
}`;
19 changes: 4 additions & 15 deletions aksel.nav.no/website/pages/gp/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { GetStaticPaths, GetStaticProps } from "next/types";
import { Suspense, lazy } from "react";
import GodPraksisPage from "@/layout/god-praksis-page/GodPraksisPage";
import {
firstArticlesQuery,
heroNavQuery,
innholdstypeQuery,
temaQuery,
} from "@/layout/god-praksis-page/queries";
import {
GpArticleListT,
Expand All @@ -24,21 +26,8 @@ const query = groq`
{
${heroNavQuery},
${innholdstypeQuery},
"tema": *[_type == "gp.tema" && slug.current == $slug][0]{
...,
"slug": slug.current,
"undertema": *[_type == "gp.tema.undertema" && tema->slug.current == $slug && count(*[_type == "aksel_artikkel" && references(^._id)]) > 0]{
title,
description
}
},
"articles": *[_type == "aksel_artikkel" && $slug in undertema[]->tema->slug.current][0...9] | order(publishedAt desc) {
heading,
ingress ,
"undertema": undertema[]->title,
"innholdstype": innholdstype->title,
"slug": slug.current
}
${temaQuery},
${firstArticlesQuery}
}
`;

Expand Down

0 comments on commit d819e73

Please sign in to comment.