Skip to content
Snippets Groups Projects
Commit 86dc145f authored by Tovo Ramontalambo's avatar Tovo Ramontalambo Committed by Julien MARGAIL
Browse files

feat/news (sort by pinned)

parent bb9fb755
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ interface INews { ...@@ -12,6 +12,7 @@ interface INews {
classname?: string classname?: string
} }
anime?: boolean anime?: boolean
size?: "xs" | "base" | "xl"
} }
const News = (props: INews) => { const News = (props: INews) => {
...@@ -21,7 +22,7 @@ const News = (props: INews) => { ...@@ -21,7 +22,7 @@ const News = (props: INews) => {
news( news(
limit: 3 limit: 3
filter: { status: { _eq: "published" } } filter: { status: { _eq: "published" } }
sort: "-date_published" sort: ["-pinned", "-date_published"]
) { ) {
id id
slug slug
...@@ -41,7 +42,7 @@ const News = (props: INews) => { ...@@ -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) => { const news = data.directus.news.map((dtNew) => {
return { return {
...@@ -49,6 +50,7 @@ const News = (props: INews) => { ...@@ -49,6 +50,7 @@ const News = (props: INews) => {
description: dtNew.content, description: dtNew.content,
image: dtNew.image?.imageFile, image: dtNew.image?.imageFile,
url: "/news/" + dtNew.slug, url: "/news/" + dtNew.slug,
size: size,
} }
}) })
......
import React, { ReactElement } from "react" 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 { function news(): ReactElement {
return ( return (
...@@ -23,6 +23,7 @@ interface INews { ...@@ -23,6 +23,7 @@ interface INews {
classname?: string; classname?: string;
}; };
anime?: boolean; anime?: boolean;
size?: "xs" | "base" | "xl";
} }
GraphQL query GraphQL query
...@@ -32,7 +33,7 @@ GraphQL query ...@@ -32,7 +33,7 @@ GraphQL query
news( news(
limit: 3 limit: 3
filter: { status: { _eq: "published" } } filter: { status: { _eq: "published" } }
sort: "-date_published" sort: ["-pinned", "-date_published"]
) { ) {
id id
content content
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment