diff --git a/cms/src/api/article/content-types/article/schema.json b/cms/src/api/article/content-types/article/schema.json index 8de2f05a14..71d2d5781f 100644 --- a/cms/src/api/article/content-types/article/schema.json +++ b/cms/src/api/article/content-types/article/schema.json @@ -43,6 +43,14 @@ "slug": { "type": "uid", "targetField": "title" + }, + "buttons": { + "type": "component", + "repeatable": true, + "component": "shared.button" + }, + "video": { + "type": "blocks" } } } diff --git a/cms/src/api/resource/content-types/resource/schema.json b/cms/src/api/resource/content-types/resource/schema.json index b1071b617c..d39ade9d00 100644 --- a/cms/src/api/resource/content-types/resource/schema.json +++ b/cms/src/api/resource/content-types/resource/schema.json @@ -35,28 +35,37 @@ "mappedBy": "resources" }, "img": { - "allowedTypes": [ - "images" - ], "type": "media", "multiple": false, - "required": true + "required": true, + "allowedTypes": [ + "images" + ] }, "link": { "type": "string" }, "file": { + "type": "media", + "multiple": false, + "required": false, "allowedTypes": [ "files" - ], - "type": "media", - "multiple": false + ] }, "pages": { "type": "relation", "relation": "manyToMany", "target": "api::page.page", "mappedBy": "resources" + }, + "buttons": { + "type": "component", + "repeatable": true, + "component": "shared.button" + }, + "video": { + "type": "blocks" } } } diff --git a/cms/types/generated/contentTypes.d.ts b/cms/types/generated/contentTypes.d.ts index f870e234de..2a8f261d9e 100644 --- a/cms/types/generated/contentTypes.d.ts +++ b/cms/types/generated/contentTypes.d.ts @@ -757,6 +757,7 @@ export interface ApiArticleArticle extends Schema.CollectionType { 'api::categorie.categorie' >; slug: Attribute.UID<'api::article.article', 'title'>; + buttons: Attribute.Component<'shared.button', true>; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; publishedAt: Attribute.DateTime; @@ -915,6 +916,7 @@ export interface ApiResourceResource extends Schema.CollectionType { 'manyToMany', 'api::page.page' >; + buttons: Attribute.Component<'shared.button', true>; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; publishedAt: Attribute.DateTime; diff --git a/public/src/app/actualites/[slug]/page.tsx b/public/src/app/actualites/[slug]/page.tsx index fa68adc7bd..2255bccaa9 100644 --- a/public/src/app/actualites/[slug]/page.tsx +++ b/public/src/app/actualites/[slug]/page.tsx @@ -1,11 +1,14 @@ +import MDContent from "@/components/common/MDContent"; import PageTitle from "@/components/common/PageTitle"; import Share from "@/components/common/Share"; import { Config } from "@/config"; +import { fetchAPI, shorten } from "@/helpers/cms"; import { fr } from "@codegouvfr/react-dsfr"; +import { ButtonProps } from '@codegouvfr/react-dsfr/Button'; +import ButtonsGroup from '@codegouvfr/react-dsfr/ButtonsGroup'; import Tag from "@codegouvfr/react-dsfr/Tag"; import Image from 'next/image'; -import { fetchAPI, shorten } from "@/helpers/cms"; -import MDContent from "@/components/common/MDContent"; +import { Button } from '../../../interfaces/cms/collectionsInterface'; export async function generateMetadata({ params }: { params: { slug: string }}) { const query = { @@ -123,6 +126,30 @@ export default async function ActuSingle({ params }: { params: { slug: string }} } + { + data.attributes.buttons && + { + return { + children:b.title, + linkProps: b.url.startsWith('http') ? { + href: b.url, + title:`${b.title} - nouvelle fenêtre` , + "aria-label":`${b.title} - nouvelle fenêtre`, + target:'_blank', + rel: "noopener noreferrer" + } : { + href: b.url, + }, + iconId: b.icon ?? '', + priority: b.color ?? 'primary', + } + }) as [ButtonProps, ...ButtonProps[]]} + buttonsIconPosition={'right'} + /> + } ); diff --git a/public/src/app/ressources/[slug]/page.tsx b/public/src/app/ressources/[slug]/page.tsx index 06822743c1..e8dfbb2c8a 100644 --- a/public/src/app/ressources/[slug]/page.tsx +++ b/public/src/app/ressources/[slug]/page.tsx @@ -1,12 +1,14 @@ +import MDContent from "@/components/common/MDContent"; import PageTitle from "@/components/common/PageTitle"; import Share from "@/components/common/Share"; import { Config } from "@/config"; +import { fetchAPI, shorten } from "@/helpers/cms"; import { fr } from "@codegouvfr/react-dsfr"; +import { ButtonProps } from "@codegouvfr/react-dsfr/Button"; +import ButtonsGroup from '@codegouvfr/react-dsfr/ButtonsGroup'; import Tag from "@codegouvfr/react-dsfr/Tag"; import Image from 'next/image'; -import { fetchAPI, shorten } from "@/helpers/cms"; -import MDContent from "@/components/common/MDContent"; -import { Button } from "@codegouvfr/react-dsfr/Button"; +import { Button } from '../../../interfaces/cms/collectionsInterface'; export async function generateMetadata({ params }: { params: { slug: string }}) { const query = { @@ -120,20 +122,29 @@ export default async function ResourceSingle({ params }: { params: { slug: strin
- {data.attributes.link && - + { + data.attributes.buttons && + { + return { + children:b.title, + linkProps: b.url.startsWith('http') ? { + href: b.url, + title:`${b.title} - nouvelle fenêtre` , + "aria-label":`${b.title} - nouvelle fenêtre`, + target:'_blank', + rel: "noopener noreferrer" + } : { + href: b.url, + }, + iconId: b.icon ?? '', + priority: b.color ?? 'primary', + } + }) as [ButtonProps, ...ButtonProps[]]} + buttonsIconPosition={'right'} + /> } {data.attributes.file.data &&
@@ -141,7 +152,7 @@ export default async function ResourceSingle({ params }: { params: { slug: strin
- {`Télécharger la ressource${data.attributes.file.data.attributes.name}`} + {`Télécharger la ressource: ${data.attributes.file.data.attributes.name}`}
diff --git a/public/src/interfaces/actualites/componentsInterface.ts b/public/src/interfaces/actualites/componentsInterface.ts index bb0106ec5a..819348a8e4 100644 --- a/public/src/interfaces/actualites/componentsInterface.ts +++ b/public/src/interfaces/actualites/componentsInterface.ts @@ -1,18 +1,21 @@ +import { Button } from "../cms/collectionsInterface"; + export interface ActuCardProps { - title: string, - content: string, - date: string, - img: string, - img_legend?: string, - href: string, - horizontal?: false | undefined, - categories: CategorieProps[] + title: string; + content: string; + date: string; + img: string; + img_legend?: string; + href: string; + horizontal?: false | undefined; + categories: CategorieProps[]; + buttons?: Button[]; } export interface CategorieProps { - id: string | number, - attributes:{ - label: string, - slug: string, - } -} \ No newline at end of file + id: string | number; + attributes: { + label: string; + slug: string; + }; +} diff --git a/public/src/interfaces/ressources/componentsInterface.ts b/public/src/interfaces/ressources/componentsInterface.ts index f43d5b1461..707930ca48 100644 --- a/public/src/interfaces/ressources/componentsInterface.ts +++ b/public/src/interfaces/ressources/componentsInterface.ts @@ -1,10 +1,13 @@ - export interface RessourceCardProps { - title: string, - content: string, - date: string, - img: string, - href:string, - link?: string, - file?: string, - horizontal?: false | undefined -} \ No newline at end of file +import { Button } from "../cms/collectionsInterface"; + +export interface RessourceCardProps { + title: string; + content: string; + date: string; + img: string; + href: string; + link?: string; + file?: string; + horizontal?: false; + buttons?: Button[]; +}