From fa3793a181d6f8845699e1e372b429796aa6e3b2 Mon Sep 17 00:00:00 2001 From: Julien Aldon Date: Tue, 21 Apr 2026 15:44:01 +0200 Subject: [PATCH] add(blockRenderer): add blockRenderer component to add link open to a new page --- .gitea/workflow/deploy.yaml | 17 -------- next/api/index.js | 13 +++--- next/app/contact/page.js | 17 ++++---- next/app/legal/page.js | 14 +++---- next/app/page.js | 50 +++++++++++----------- next/app/prog/village/page.js | 56 ++++++++++++------------- next/components/articleBlock/index.jsx | 37 ++++++++-------- next/components/blockRenderer/index.jsx | 18 ++++++++ next/components/timeSlot/index.jsx | 39 ++++++++--------- 9 files changed, 132 insertions(+), 129 deletions(-) delete mode 100644 .gitea/workflow/deploy.yaml create mode 100644 next/components/blockRenderer/index.jsx diff --git a/.gitea/workflow/deploy.yaml b/.gitea/workflow/deploy.yaml deleted file mode 100644 index 9e4b884..0000000 --- a/.gitea/workflow/deploy.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Deploy Fefan -on: - push: - branches: - - main - workflow_dispatch: -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Build & deploy - run: | - git pull - docker compose up -d --build \ No newline at end of file diff --git a/next/api/index.js b/next/api/index.js index 0f56f1f..c16d4a1 100644 --- a/next/api/index.js +++ b/next/api/index.js @@ -1,16 +1,17 @@ -import qs from "qs"; +import qs from 'qs'; async function getData(path, query) { const queryString = qs.stringify(query); - const isServerSide = typeof window === "undefined"; + const isServerSide = typeof window === 'undefined'; const res = await fetch( `${ isServerSide - ? process.env.NEXT_PRIVATE_CONTENT_URI ?? - "http://fefan-backend:1337/api" - : process.env.NEXT_PUBLIC_CONTENT_URI ?? "https://content.fefan.fr/api" + ? (process.env.NEXT_PRIVATE_CONTENT_URI ?? + 'http://fefan-backend:1337/api') + : (process.env.NEXT_PUBLIC_CONTENT_URI ?? + 'https://content.fefan.fr/api') }/${path}?${queryString}`, - { cache: "no-store" } + { cache: 'no-store' }, ); return await res.json(); diff --git a/next/app/contact/page.js b/next/app/contact/page.js index b5d681f..7ed84bd 100644 --- a/next/app/contact/page.js +++ b/next/app/contact/page.js @@ -1,23 +1,22 @@ -import getData from "@/api"; -import { BlocksRenderer } from "@strapi/blocks-react-renderer"; -import styles from "./style.module.scss"; -import Email from "@/components/email"; -export const dynamic = "force-dynamic"; +import getData from '@/api'; +import BlockRenderer from '@/components/blockRenderer'; +import Email from '@/components/email'; +import styles from './style.module.scss'; +export const dynamic = 'force-dynamic'; export async function generateMetadata() { return { metadataBase: `${process.env.NEXT_PUBLIC_ORIGIN}`, - title: "Contactez nous !", + title: 'Contactez nous !', }; } export default async function Contact() { - const site = await getData("site", {}); - + const site = await getData('site', {}); const content = site.data?.attributes.contact_text; return (
-
{content ? : null}
+
{content ? : null}
{site.data?.attributes.contact_mail ? : null}
); diff --git a/next/app/legal/page.js b/next/app/legal/page.js index b8b071f..df8364c 100644 --- a/next/app/legal/page.js +++ b/next/app/legal/page.js @@ -1,22 +1,22 @@ -import getData from "@/api"; -import { BlocksRenderer } from "@strapi/blocks-react-renderer"; -import styles from "./style.module.scss"; -export const dynamic = "force-dynamic"; +import getData from '@/api'; +import BlockRenderer from '@/components/blockRenderer'; +import styles from './style.module.scss'; +export const dynamic = 'force-dynamic'; export async function generateMetadata() { return { metadataBase: `${process.env.NEXT_PUBLIC_ORIGIN}`, - title: "Mentions légales", + title: 'Mentions légales', }; } export default async function Legal() { - const site = await getData("site", {}); + const site = await getData('site', {}); const content = site.data?.attributes.legal; return (
-
{content ? : null}
+
{content ? : null}
); } diff --git a/next/app/page.js b/next/app/page.js index 79e61e8..baa8834 100644 --- a/next/app/page.js +++ b/next/app/page.js @@ -1,31 +1,31 @@ -import getData from "@/api"; -import styles from "./page.module.scss"; -import { BlocksRenderer } from "@strapi/blocks-react-renderer"; -import Button from "@/components/button"; -import ImageBlock from "@/components/imageBlock"; -export const dynamic = "force-dynamic"; +import getData from '@/api'; +import BlockRenderer from '@/components/blockRenderer'; +import Button from '@/components/button'; +import ImageBlock from '@/components/imageBlock'; +import styles from './page.module.scss'; +export const dynamic = 'force-dynamic'; export async function generateMetadata() { - const site = await getData("site", { + const site = await getData('site', { populate: { edition: { populate: { flyer: { fields: [ - "name", - "url", - "alternativeText", - "caption", - "width", - "height", + 'name', + 'url', + 'alternativeText', + 'caption', + 'width', + 'height', ], }, programs: true, }, - fields: ["id", "introduction", "title", "subtitle", "description"], + fields: ['id', 'introduction', 'title', 'subtitle', 'description'], }, }, - fields: ["author"], + fields: ['author'], }); const current_edition = site.data?.attributes.edition.data?.attributes; const flyer = @@ -37,7 +37,7 @@ export async function generateMetadata() { title: current_edition.title, description: current_edition.description, alternates: { - canonical: "/", + canonical: '/', }, openGraph: { title: current_edition.title, @@ -49,25 +49,25 @@ export async function generateMetadata() { height: flyer.height, }, authors: [site.data.attributes.author], - type: "website", - locale: "fr_FR", - siteName: "Le Fefan - Festival de Fanfares", + type: 'website', + locale: 'fr_FR', + siteName: 'Le Fefan - Festival de Fanfares', }, } : {}; } export default async function Home() { - const site = await getData("site", { + const site = await getData('site', { populate: { edition: { populate: { flyer: { - fields: ["name", "url", "alternativeText", "caption"], + fields: ['name', 'url', 'alternativeText', 'caption'], }, programs: true, }, - fields: ["id", "introduction", "title", "subtitle"], + fields: ['id', 'introduction', 'title', 'subtitle'], }, }, }); @@ -91,15 +91,15 @@ export default async function Home() {

{current_edition.title}

{current_edition.subtitle}

- {introduction ? : null} + {introduction ? : null}
- ); +export default function ArticleBlock({ + title, + content, + link, + className, + ...props +}) { + return ( +
+

{title}

+ {content ? : null} + +
+ ); } diff --git a/next/components/blockRenderer/index.jsx b/next/components/blockRenderer/index.jsx new file mode 100644 index 0000000..aeed78e --- /dev/null +++ b/next/components/blockRenderer/index.jsx @@ -0,0 +1,18 @@ +'use client'; +import { BlocksRenderer } from '@strapi/blocks-react-renderer'; +import Link from 'next/link'; + +export default function BlockRenderer({ content }) { + return ( + ( + + {children} + + ), + }} + /> + ); +} diff --git a/next/components/timeSlot/index.jsx b/next/components/timeSlot/index.jsx index df6cebe..748a4ac 100644 --- a/next/components/timeSlot/index.jsx +++ b/next/components/timeSlot/index.jsx @@ -1,23 +1,24 @@ -import { BlocksRenderer } from '@strapi/blocks-react-renderer'; +import BlockRenderer from '@/components/blockRenderer'; import styles from './style.module.scss'; export default async function TimeSlot(props) { - const date_begin = new Date(props.start) - const date_end = new Date(props.end) - const date_format = new Intl.DateTimeFormat('fr', { - weekday: 'long', - month: "long", - day: "numeric" - }).format(date_begin) + const date_begin = new Date(props.start); + const date_end = new Date(props.end); + const date_format = new Intl.DateTimeFormat('fr', { + weekday: 'long', + month: 'long', + day: 'numeric', + }).format(date_begin); - return ( -
-

- {date_format} - {date_begin.getHours()}h - {date_begin.getMinutes() !== 0 ? date_begin.getMinutes() : ""} à  - {date_end.getHours()}h{date_end.getMinutes() !== 0 ? date_end.getMinutes() : ""} -

- -
- ); -} \ No newline at end of file + return ( +
+

+ {date_format} - {date_begin.getHours()}h + {date_begin.getMinutes() !== 0 ? date_begin.getMinutes() : ''} à  + {date_end.getHours()}h + {date_end.getMinutes() !== 0 ? date_end.getMinutes() : ''} +

+ +
+ ); +}