From 86dc145f31fd8c4b343f872f2c71b892feea3ade Mon Sep 17 00:00:00 2001 From: Tovo Ramontalambo <ta.ramontalambo@geofit.fr> Date: Tue, 17 Jan 2023 08:23:35 +0000 Subject: [PATCH] feat/news (sort by pinned) --- src/components/News.tsx | 6 ++++-- src/pages-doc/doc/news.tsx | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/News.tsx b/src/components/News.tsx index 5c84983..8e904cd 100644 --- a/src/components/News.tsx +++ b/src/components/News.tsx @@ -12,6 +12,7 @@ interface INews { classname?: string } anime?: boolean + size?: "xs" | "base" | "xl" } const News = (props: INews) => { @@ -21,7 +22,7 @@ const News = (props: INews) => { news( limit: 3 filter: { status: { _eq: "published" } } - sort: "-date_published" + sort: ["-pinned", "-date_published"] ) { id slug @@ -41,7 +42,7 @@ const News = (props: INews) => { } `) - const { title = "", anime = true, action } = props + const { title = "", anime = true, action, size = "xs" } = props const news = data.directus.news.map((dtNew) => { return { @@ -49,6 +50,7 @@ const News = (props: INews) => { description: dtNew.content, image: dtNew.image?.imageFile, url: "/news/" + dtNew.slug, + size: size, } }) diff --git a/src/pages-doc/doc/news.tsx b/src/pages-doc/doc/news.tsx index dc54505..1e69eef 100644 --- a/src/pages-doc/doc/news.tsx +++ b/src/pages-doc/doc/news.tsx @@ -1,7 +1,7 @@ import React, { ReactElement } from "react" -import { } from "gatsby" +import {} from "gatsby" -import { Content,Link ,News } from "@onegeo/gatsby-theme-onegeo" +import { Content, Link, News } from "@onegeo/gatsby-theme-onegeo" function news(): ReactElement { return ( @@ -23,6 +23,7 @@ interface INews { classname?: string; }; anime?: boolean; + size?: "xs" | "base" | "xl"; } GraphQL query @@ -32,7 +33,7 @@ GraphQL query news( limit: 3 filter: { status: { _eq: "published" } } - sort: "-date_published" + sort: ["-pinned", "-date_published"] ) { id content -- GitLab