[Nom de l'Interface de Recherche]
Type de ressource : Interface Utilisateur Pagefind (Barre de recherche / Résultats / Filtres)
Fichier source :src/components/ui/SearchBar.astroou composant associé
Statut : [Actif / Déprécié / En développement]
Slice : [Numéro de la tranche verticale]
Version : 1.0
1. Vue dâensemble (DOC)
Section titled â1. Vue dâensemble (DOC)â1.1. Description
Section titled â1.1. Descriptionâ[Description concise du rĂŽle de cette interface de recherche dans lâexpĂ©rience utilisateur]
1.2. Objectif
Section titled â1.2. Objectifâ- [Objectif principal : ex. fournir une recherche unifiĂ©e sur lâensemble du site]
- [BĂ©nĂ©fice pour lâutilisateur : ex. trouver rapidement du contenu dans le blog, le portfolio ou la documentation]
1.3. PérimÚtre concerné
Section titled â1.3. PĂ©rimĂštre concernĂ©â| Couverture | Statut |
|---|---|
| Vitrine | [â /â] |
| Blog | [â /â] |
| Portfolio | [â /â] |
| Documentation | [â /â] |
| Tout | [â /â] |
| Emplacement | Statut |
|---|---|
| Header global | [â /â] |
| Sidebar | [â /â] |
| Page dĂ©diĂ©e | [â /â] |
| Modal | [â /â] |
| Type dâinterface | Statut |
|---|---|
| Pagefind UI natif | [â /â] |
| Composant custom | [â /â] |
| Les deux | [â /â] |
2. Architecture et flux (DOC)
Section titled â2. Architecture et flux (DOC)â2.1. Diagramme de flux
Section titled â2.1. Diagramme de fluxâ[Utilisateur] â (saisie dans la barre de recherche) âŒ[Composant SearchBar] â âą Initialisation Pagefind â âą Chargement de l'index chunkĂ© â âą Recherche cĂŽtĂ© client âŒ[Pagefind (client-side)] â âą Matching des termes â âą Application des filtres â âą Ranking des rĂ©sultats âŒ[Affichage des rĂ©sultats] â âą Distinction visuelle par type â âą Badges (Doc, Blog, Portfolio, Page) â âą Pagination âŒ[Utilisateur] â (clic sur un rĂ©sultat) âŒ[Navigation vers la page]2.2. Composants impliquĂ©s
Section titled â2.2. Composants impliquĂ©sâ| Composant | RĂŽle | Fichier |
|---|---|---|
SearchBar.astro |
Interface de recherche globale | src/components/ui/SearchBar.astro |
SearchResults.astro |
Affichage des résultats | src/components/ui/SearchResults.astro |
SearchFilters.astro |
Filtres par type de contenu | src/components/ui/SearchFilters.astro |
| Pagefind UI | BibliothĂšque JS de recherche | pagefind-ui (npm) |
| Index Pagefind | Index chunké généré au build | dist/_pagefind/ |
3. Implémentation (CODE)
Section titled â3. ImplĂ©mentation (CODE)â3.1. Variante : Pagefind UI natif
Section titled â3.1. Variante : Pagefind UI natifâ<div id="search"></div>
<script> import { Search } from 'pagefind-ui';
window.addEventListener('DOMContentLoaded', () => { new Search({ element: '#search', pageSize: 10, showSubResults: true, showImages: false, processTerm: (term) => { // Normalisation des termes de recherche return term.toLowerCase().trim(); }, processResult: (result) => { // Personnalisation des résultats const type = result.meta?.type || 'page'; const badge = { docs: 'Doc', blog: 'Blog', portfolio: 'Portfolio', page: 'Page', }[type] || 'Page';
return { ...result, badge, }; }, }); });</script>3.2. Variante : Composant custom
Section titled â3.2. Variante : Composant customâ<div class="search-container"> <input type="search" id="search-input" placeholder="Rechercher..." class="search-input" />
<div id="search-results" class="search-results"> <!-- Résultats injectés dynamiquement --> </div></div>
<style> .search-container { position: relative; }
.search-input { width: 100%; padding: 0.5rem 1rem; border: 1px solid #e5e7eb; border-radius: 0.375rem; }
.search-results { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #e5e7eb; border-radius: 0.375rem; max-height: 400px; overflow-y: auto; }</style>4. Contrats dâEntrĂ©e/Sortie (SPEC)
Section titled â4. Contrats dâEntrĂ©e/Sortie (SPEC)â4.1. Inputs (Saisie utilisateur)
Section titled â4.1. Inputs (Saisie utilisateur)â| ParamĂštre | Type | Validation |
|---|---|---|
query |
string |
Non vide aprĂšs debounce |
4.2. Outputs (Affichage)
Section titled â4.2. Outputs (Affichage)â| ĂlĂ©ment | Type | Description |
|---|---|---|
results |
HTMLElement |
Liste des résultats |
badges |
HTMLElement |
Badges de type |
5. Tests attendus (TEST)
Section titled â5. Tests attendus (TEST)â5.1. Tests unitaires
Section titled â5.1. Tests unitairesâ| ScĂ©nario | Description | RĂ©sultat attendu |
|---|---|---|
| Rendu | Composant monté | Interface affichée |
| Input | Saisie utilisateur | Recherche déclenchée |
5.2. Tests dâintĂ©gration
Section titled â5.2. Tests dâintĂ©grationâ| ScĂ©nario | DĂ©pendances | Description | RĂ©sultat attendu |
|---|---|---|---|
| Flux complet | Index + UI | Recherche â Navigation | RĂ©sultats cliquables |
6. IntĂ©gration (INTĂG)
Section titled â6. IntĂ©gration (INTĂG)â6.1. IntĂ©gration avec les composants
Section titled â6.1. IntĂ©gration avec les composantsâ| Composant | Type | RĂŽle | MĂ©thode dâintĂ©gration |
|---|---|---|---|
| Header | L2 | Emplacement | Composant inclus |
| Index | Build | Données | Pagefind CLI |
6.2. Points dâattention
Section titled â6.2. Points dâattentionâ- Lâinterface doit ĂȘtre accessible
- Les badges doivent ĂȘtre cohĂ©rents
- La pagination doit fonctionner
6.3. Vérification de cohérence
Section titled â6.3. VĂ©rification de cohĂ©renceâ- Lâinterface est accessible
- Les rĂ©sultats sâaffichent
- Les badges sont corrects
- Les tests E2E passent
7. Sécurité
Section titled â7. SĂ©curitĂ©â7.1. MĂ©canismes de sĂ©curitĂ©
Section titled â7.1. MĂ©canismes de sĂ©curitĂ©â- â Sanitization des rĂ©sultats
- â Protection XSS
7.2. RÚgles de sécurité
Section titled â7.2. RĂšgles de sĂ©curitĂ©â- â Valider les entrĂ©es
- â Ăchapper le HTML
8. Performance et limites
Section titled â8. Performance et limitesâ8.1. Limites
Section titled â8.1. Limitesâ| Limite | Valeur |
|---|---|
| Résultats par page | 10-20 |
| Temps de recherche | < 500ms |
8.2. Optimisations
Section titled â8.2. Optimisationsâ- â Debounce
- â Pagination
- â Lazy loading
9. Débogage et troubleshooting
Section titled â9. DĂ©bogage et troubleshootingâ9.1. ProblĂšmes courants
Section titled â9.1. ProblĂšmes courantsâ| SymptĂŽme | Cause probable | Solution |
|---|---|---|
| Résultats non affichés | Erreur JS | Vérifier la console |
| Badges incorrects | MĂ©tadonnĂ©es manquantes | VĂ©rifier lâindexation |
9.2. Commandes de debug
Section titled â9.2. Commandes de debugâ# Build localnpm run build
# Previewnpm run preview10. Bonnes pratiques
Section titled â10. Bonnes pratiquesâ10.1. Architecture
Section titled â10.1. Architectureâ- â AccessibilitĂ© (ARIA)
- â Responsive design
- â CohĂ©rence visuelle
10.2. Code
Section titled â10.2. Codeâ- â TypeScript strict
- â Gestion des erreurs
- â Documentation
11. Ăvolutions et roadmap
Section titled â11. Ăvolutions et roadmapâ11.1. AmĂ©liorations planifiĂ©es
Section titled â11.1. AmĂ©liorations planifiĂ©esâ- [Ăvolution 1]
- [Ăvolution 2]
11.2. Limitations connues
Section titled â11.2. Limitations connuesâ- â [Limitation 1]
- â [Limitation 2]
12. Ressources liées
Section titled â12. Ressources liĂ©esâ- Documentation Pagefind : UI Reference
13. Historique des modifications
Section titled â13. Historique des modificationsâ| Date | Version | Description | Auteur |
|---|---|---|---|
| YYYY-MM-DD | 1.0 | Création initiale | [Nom] |