From 10d5238f3a8b7d40a5cad11ac96c8a32ed651a1e Mon Sep 17 00:00:00 2001 From: ElPoyo Date: Mon, 2 Mar 2026 14:05:19 +0100 Subject: [PATCH] feat: Refactor search functionality and integrate WordPress as Headless CMS - Introduced a unified search service (`searchService.js`) for texts and blog posts. - Redesigned the search page (`Texts.vue`) with improved filters and pagination. - Enhanced navigation bar (`NavigationBar.vue`) for better user experience. - Added WordPress integration for news articles with a dedicated service (`wordpressService.js`). - Created a new About page (`AboutPage.vue`) detailing the association's history and values. - Updated backend API to support new endpoints and optimizations. - Implemented caching and performance improvements for search queries. --- backend/server.js | 24 +- src/components/FooterComponent.vue | 17 ++ src/components/NavigationBar.vue | 2 + src/router/index.js | 12 +- src/services/searchService.js | 291 +++++++++++++++++++ src/services/textService.js | 2 +- src/services/wordpressService.js | 46 +++ src/views/AboutPage.vue | 159 +++++++++++ src/views/Home.vue | 175 ++++++++++-- src/views/Texts.vue | 442 ++++++++++++++++++++--------- 10 files changed, 1016 insertions(+), 154 deletions(-) create mode 100644 src/services/searchService.js create mode 100644 src/views/AboutPage.vue diff --git a/backend/server.js b/backend/server.js index c7d519d..440419a 100644 --- a/backend/server.js +++ b/backend/server.js @@ -270,7 +270,10 @@ class TextService { // Filtres if (filters.category) { - results = results.filter(text => text.metadata.categorie === filters.category) + const categoryLower = filters.category.toLowerCase() + results = results.filter(text => + text.metadata.categorie?.toLowerCase() === categoryLower + ) } if (filters.difficulty) { @@ -285,7 +288,7 @@ class TextService { } /** - * NOUVEAU : Obtient toutes les catégories disponibles + * NOUVEAU : Obtient toutes les catégories disponibles (normalisées en minuscules) */ async getCategories() { const allTexts = await this.scanTexts() @@ -293,7 +296,8 @@ class TextService { for (const text of allTexts) { if (text.metadata.categorie) { - categories.add(text.metadata.categorie) + // Normaliser en minuscules + categories.add(text.metadata.categorie.toLowerCase()) } } @@ -404,6 +408,19 @@ app.get('/api/stats', async (req, res) => { } }) +/** + * GET /api/categories - Liste des catégories disponibles + */ +app.get('/api/categories', async (req, res) => { + try { + const categories = await textService.getCategories() + res.json(categories) + } catch (error) { + console.error('Erreur GET /api/categories:', error) + res.status(500).json({ error: 'Erreur lors du chargement des catégories' }) + } +}) + /** * GET /api/texts/:id/audio - Fichier audio */ @@ -439,6 +456,7 @@ app.listen(PORT, () => { console.log(` GET /api/texts/:id - Détails d'un texte`) console.log(` GET /api/random - Texte aléatoire`) console.log(` GET /api/stats - Statistiques`) + console.log(` GET /api/categories - Liste des catégories`) console.log(` GET /api/texts/:id/audio - Fichier audio`) }) diff --git a/src/components/FooterComponent.vue b/src/components/FooterComponent.vue index 1445de6..f65083a 100644 --- a/src/components/FooterComponent.vue +++ b/src/components/FooterComponent.vue @@ -1,6 +1,23 @@