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.
This commit is contained in:
ElPoyo
2026-03-02 14:05:19 +01:00
parent 03ffc846bf
commit 10d5238f3a
10 changed files with 1016 additions and 154 deletions

View File

@@ -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`)
})