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

feat(sandbox): card retrieval for a unique editorial dashboard #1154

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a53e828
feat: sandbox to test card retrieval
Fupete Dec 20, 2023
726f9eb
Merge branch 'main' into feat-card-retrieval-for-an-unique-editorial-…
Fupete Dec 20, 2023
f13cec8
fix: typo
Fupete Dec 21, 2023
18187b8
Merge branch 'feat-card-retrieval-for-an-unique-editorial-dashboard-2…
Fupete Dec 21, 2023
ab5e0f6
fix: lint
Fupete Dec 21, 2023
f934a5c
Merge branch 'main' into feat-card-retrieval-for-an-unique-editorial-…
Fupete Dec 21, 2023
e643aab
fix: mispelled seo property pathname vs url
Fupete Dec 21, 2023
6ac04e9
fix: typo
Fupete Dec 21, 2023
595d1d8
fix: formatting
Fupete Dec 21, 2023
cbff7c6
fix: lint query
Fupete Dec 21, 2023
c5fe300
feat: enabled on main query a second query to allContent
Fupete Dec 21, 2023
d648117
fix: lint
Fupete Dec 21, 2023
3ea773b
feat: possible dashboard yaml setting
Fupete Dec 21, 2023
9eab7a6
feat: evolve and compare static vs page query
Fupete Dec 21, 2023
38a3466
fix: lint
Fupete Dec 21, 2023
f8f7f93
fix: indentation
Fupete Dec 21, 2023
699b1b9
fix: typo
Fupete Dec 21, 2023
6e553b2
feat: highighted context variable
Fupete Dec 21, 2023
e9fbabc
feat: highlightedCards
Fupete Dec 21, 2023
71cea90
fix: typo
Fupete Dec 21, 2023
8bb8f48
feat: lint setting
Fupete Dec 21, 2023
f7347ef
content: description
Fupete Dec 21, 2023
324f486
fix: lint
Fupete Dec 21, 2023
f67880b
fix: lint
Fupete Dec 21, 2023
b6ee81d
fix: cleanup
Fupete Dec 22, 2023
aaea5a8
Merge branch 'feat-card-retrieval-for-an-unique-editorial-dashboard-2…
Fupete Dec 22, 2023
a473a76
feat: add editorial board settings as a dedicated graphql schema
Fupete Dec 22, 2023
86a3cc3
fix: name file
Fupete Dec 22, 2023
a6171e5
fix: lint
Fupete Dec 22, 2023
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
23 changes: 23 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,29 @@ exports.onCreateNode = async ({
}
};

/* eslint-disable consistent-return */ // just setting a context variable
Fupete marked this conversation as resolved.
Show resolved Hide resolved
exports.onCreatePage = ({ page, actions }) => {
// add variables to pageContext
if (page.context.highlighted) {
return "Skipping already highlighted page";
}
const { createPage, deletePage } = actions;

deletePage(page);
createPage({
...page,
context: {
...page.context,
highlighted: [
"Il 2023 di Designers Italia ",
"Esperienza del cittadino nei servizi pubblici: dalla Misura alla pratica",
"Prendi parte anche tu all’evoluzione del design system del Paese",
"Modelli di siti e servizi di Designers Italia: nuovi file in formato aperto",
],
},
});
};

exports.createPages = async ({ graphql, actions }) => {
// tags
const { createPage } = actions;
Expand Down
51 changes: 51 additions & 0 deletions src/components/highlighted-cards/highlighted-cards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from "react";

import Card from "../card/card";

function HighlightedCards({ data }) {
const cardStyles = "col-12 col-md-6 mb-3 mb-md-4 col-lg-4";

return (
<section
className="section-editorial"
aria-describedby="sandbox-list-title"
>
<div className="container-xxl">
<div className="row">
<div className="col-12 g-0">
<div className="px-3 px-lg-0 px-lg-5">
<h2
className="border-bottom pb-4 mb-4 mb-md-5"
id="sandbox-list-title"
>
Sandbox page query
</h2>
<div className="lead mb-5">
Cards loaded from an array of titles stored in gatsbynode and used via a global pageQuery All is a sandbox

Check failure on line 24 in src/components/highlighted-cards/highlighted-cards.js

View workflow job for this annotation

GitHub Actions / tests

Insert `⏎···············`
</div>
<div className="row pb-4">
{data.edges.map(({ node }) => (
<div key={node.seo.title} className={cardStyles}>
<Card
img={node.components.imageIcons.image}
title={node.components.hero.title}
url={node.seo.pathname}
description={node.seo.description}
fullHeight
// tag={node.components.hero.tag}
tags={node.components.hero.kangaroo.tags}
/>
{/* <h3><Link to={node.seo.pathname}>{node.components.hero.title}</Link></h3> */}
{/* <p>{node.seo.description}</p> */}
</div>
))}
</div>
</div>
</div>
</div>
</div>
</section>
);
}

export default HighlightedCards;
45 changes: 45 additions & 0 deletions src/data/highlighted-cards.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# (SANDBOX)
# Dashboard file to check all the highlighted editorial cards on the various pages
# Maybe "title"s are not the best way to...

highlightedCards:
- page: "home"
sections:
- section: "community"
cards:
- title: "Il 2023 di Designers Italia"
- title: "Per una progettazione a misura di territorio"
- title: "Cantiere Designers Italia"

- page: "designsystem"
sections:
- section: "community"
cards:
- title: "Il 2023 di Designers Italia"
- title: "Per una progettazione a misura di territorio"
- title: "Democratising co-production of sustainable public services"

- page: "community"
sections:
- section: "news"
cards:
- title: "Il 2023 di Designers Italia"
- title: "Per una progettazione a misura di territorio"
- title: "Cantiere Designers Italia"
- section: "events"
cards:
- title: "L’architettura informativa del modello Comuni. Organizzare i contenuti per realizzare un sito facile da consultare"
- title: "Niente su di Noi, senza di Noi"
- title: "Forum PA 2023 - Servizi e piattaforme per la cittadinanza digitale"
- title: "Democratising co-production of sustainable public services"
- section: "media"
cards:
- title: "Il design system del Paese per realizzare siti e servizi dei Comuni"
- title: "Niente su di Noi, senza di Noi - La sfida accolta da Designers Italia, AGID e Accessibility Days"
- title: "ll design system del Paese e la responsabilità di progettare interfacce pubbliche"
- title: "Servizi inclusivi e usabili per tutti"
# - section: "articles"
# cards:
# - url: "#" # XXX medium (futurability)
# - url: "#" # XXX medium (futurability)
# - url: "#" # XXX medium (futurability)
37 changes: 34 additions & 3 deletions src/pages/{content.relativePath}.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const TEMPLATES = {
"design-system-component": TemplateDSComponent,
};

function Page({ pageContext, location, data: { content } }) {
function Page({ pageContext, location, data: { content, highlightedCards } }) {
const Template = content.metadata.template
? TEMPLATES[content.metadata.template.name]
: TemplateBase;
Expand All @@ -47,6 +47,7 @@ function Page({ pageContext, location, data: { content } }) {
return (
<Template
Pagedata={content}
highlightedCards={highlightedCards}
pageContext={pageContext}
location={location}
lastModified={lastModified}
Expand All @@ -57,7 +58,38 @@ function Page({ pageContext, location, data: { content } }) {
}

export const query = graphql`
query ($id: String!) {
query ($id: String!, $highlighted: [String!]!) {
highlightedCards: allContent(
filter: { components: { hero: { title: { in: $highlighted } } } }
sort: { seo: { pathname: DESC } }
) {
totalCount
edges {
node {
seo {
description
pathname
image
}
components {
hero {
title
tag {
label
addonClasses
}
kangaroo {
tags
}
}
imageIcons {
image
alt
}
}
}
}
}
content(id: { eq: $id }) {
id
parent {
Expand All @@ -67,7 +99,6 @@ export const query = graphql`
}
}
}

metadata {
template {
name
Expand Down
11 changes: 10 additions & 1 deletion src/templates/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ import BannerTextCta from "../components/banner-text-cta/banner-text-cta";
import Numbers from "../components/numbers/numbers";
import ImageIcons from "../components/image-icons/image-icons";

function Template({ Pagedata, pageContext, location, lastModified }) {
import HighlightedCards from "../components/highlighted-cards/highlighted-cards";

function Template({
Pagedata,
highlightedCards,
pageContext,
location,
lastModified,
}) {
return (
<div id="app">
<HeaderPre data={HeaderData.headerPre} location={location} />
Expand All @@ -43,6 +51,7 @@ function Template({ Pagedata, pageContext, location, lastModified }) {
</Header>
<HeaderPost data={HeaderData.headerPost} />
<main id="main">
<HighlightedCards data={highlightedCards} />
<Highlight {...Pagedata.components.hero}>
{Pagedata.components.hero.moreText && (
<ContentCollapse
Expand Down
Loading