Type de ressource : Route Astro (Page SSG)
Fichier source :src/pages/blog/index.astro
Statut : Actif
1. Vue dâensemble
Section titled â1. Vue dâensembleâ1.1. Description
Section titled â1.1. DescriptionâPage dâindex du blog affichant la liste de tous les articles. Utilise Astro content collections pour rĂ©cupĂ©rer les articles. Affiche les articles dans une grille avec lâimage hĂ©ro, le titre et la date de publication.
1.2. Objectif
Section titled â1.2. Objectifâ- Afficher la liste des articles de blog
- Fournir une navigation vers les articles individuels
- Tester lâintĂ©gration Astro content collections
1.3. Caractéristiques
Section titled â1.3. CaractĂ©ristiquesâ| PropriĂ©tĂ© | Valeur |
|---|---|
| URL publique | /blog |
| Mode de rendu | SSG |
| Type | Page HTML |
| Méthode HTTP | GET |
| Authentification requise | Non |
| Cache | Par défaut Cloudflare |
2. Architecture et flux
Section titled â2. Architecture et fluxâ[RequĂȘte utilisateur] â âŒ[Cloudflare Pages / Edge] â âą Routage vers Astro âŒ[Astro Route (blog/index.astro)] â âą RĂ©cupĂ©ration des articles via getCollection('blog') â âą Tri par date de publication â âą Rendu de la grille d'articles âŒ[RĂ©ponse HTML]2.2. Composants impliquĂ©s
Section titled â2.2. Composants impliquĂ©sâ| Composant | RĂŽle | Couche |
|---|---|---|
blog/index.astro |
Définition de la route | L2 (Astro) |
getCollection('blog') |
Récupération des articles | L2 (Astro) |
BaseHead |
Métadonnées SEO globales | L2 (Astro) |
Header |
Navigation globale | L2 (Astro) |
Footer |
Pied de page global | L2 (Astro) |
FormattedDate |
Formatage des dates | L2 (Astro) |
3. Implémentation
Section titled â3. ImplĂ©mentationâ3.1. Code de la route
Section titled â3.1. Code de la routeâ---import { Image } from 'astro:assets';import { getCollection } from 'astro:content';import BaseHead from '../../components/BaseHead.astro';import Footer from '../../components/Footer.astro';import FormattedDate from '../../components/FormattedDate.astro';import Header from '../../components/Header.astro';import { SITE_DESCRIPTION, SITE_TITLE } from '../../consts';
const posts = (await getCollection('blog')).sort( (a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf(),);---
<!doctype html><html lang="en"> <head> <BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} /> <style> main { width: 960px; } ul { display: flex; flex-wrap: wrap; gap: 2rem; list-style-type: none; margin: 0; padding: 0; } ul li { width: calc(50% - 1rem); } /* ... styles responsive ... */ </style> </head> <body> <Header /> <main> <section> <ul> { posts.map((post) => ( <li> <a href={`/blog/${post.id}/`}> {post.data.heroImage && ( <Image width={720} height={360} src={post.data.heroImage} alt="" /> )} <h4 class="title">{post.data.title}</h4> <p class="date"> <FormattedDate date={post.data.pubDate} /> </p> </a> </li> )) } </ul> </section> </main> <Footer /> </body></html>4. DonnĂ©es et requĂȘtes GROQ
Section titled â4. DonnĂ©es et requĂȘtes GROQâ4.1. RequĂȘte principale
Section titled â4.1. RequĂȘte principaleâAucune requĂȘte GROQ nâest utilisĂ©e (Astro content collections).
4.2. RequĂȘtes secondaires
Section titled â4.2. RequĂȘtes secondairesâAucune requĂȘte secondaire nâest utilisĂ©e.
4.3. Types TypeScript associés
Section titled â4.3. Types TypeScript associĂ©sâ// Type CollectionEntry gĂ©nĂ©rĂ© par Astroexport type CollectionEntry<TCollectionName> = { id: string; slug: string; body: string; collection: TCollectionName; data: { title: string; description: string; pubDate: Date; updatedDate?: Date; heroImage?: ImageMetadata; };};5. ParamĂštres et validation
Section titled â5. ParamĂštres et validationâ5.1. ParamĂštres dâURL
Section titled â5.1. ParamĂštres dâURLâAucun paramĂštre dâURL nâest utilisĂ©.
5.2. Query strings
Section titled â5.2. Query stringsâAucune query string nâest utilisĂ©e.
5.3. Gestion des erreurs
Section titled â5.3. Gestion des erreursâ| Code HTTP | Condition | RĂ©ponse |
|---|---|---|
| 200 | SuccĂšs | Page HTML |
| 500 | Erreur content collections | Page dâerreur Astro |
6. Stratégie de cache
Section titled â6. StratĂ©gie de cacheâ6.1. En-tĂȘtes de cache
Section titled â6.1. En-tĂȘtes de cacheâ| Mode | Cache-Control |
CDN-Cache-Control |
Rationale |
|---|---|---|---|
| SSG (build time) | Non configuré | Non configuré | Par défaut Cloudflare |
6.2. Implémentation dans la route
Section titled â6.2. ImplĂ©mentation dans la routeâNon implĂ©mentĂ© - pas de headers de cache explicites.
7. SEO et métadonnées
Section titled â7. SEO et mĂ©tadonnĂ©esâ7.1. Balises meta
Section titled â7.1. Balises metaâ| Balise | Source | Fallback |
|---|---|---|
<title> |
SITE_TITLE (const) |
- |
<meta name="description"> |
SITE_DESCRIPTION (const) |
- |
| Meta tags globaux | BaseHead |
- |
7.2. Sitemap
Section titled â7.2. Sitemapâ- â Cette route est-elle incluse dans le sitemap ? Oui
- â FrĂ©quence de mise Ă jour : daily
- â PrioritĂ© : 0.8
7.3. Indexation Pagefind
Section titled â7.3. Indexation Pagefindâ- â Cette route est-elle indexĂ©e par Pagefind ? Non (Pagefind non configurĂ©)
8. Composants UI utilisés
Section titled â8. Composants UI utilisĂ©sâ| Composant | Fichier | RĂŽle | Hydratation |
|---|---|---|---|
BaseHead |
src/components/BaseHead.astro |
Métadonnées SEO | Aucune |
Header |
src/components/Header.astro |
Navigation globale | Aucune |
Footer |
src/components/Footer.astro |
Pied de page global | Aucune |
FormattedDate |
src/components/FormattedDate.astro |
Formatage des dates | Aucune |
9. Sécurité
Section titled â9. SĂ©curitĂ©â9.1. AccĂšs et authentification
Section titled â9.1. AccĂšs et authentificationâ| Condition | Comportement |
|---|---|
| AccĂšs public | Page accessible sans authentification |
9.2. Validation des entrées
Section titled â9.2. Validation des entrĂ©esâNon applicable (pas de paramĂštres dâentrĂ©e).
9.3. En-tĂȘtes de sĂ©curitĂ©
Section titled â9.3. En-tĂȘtes de sĂ©curitĂ©âNon implĂ©mentĂ© dans cette route (Ă configurer via Middleware Cloudflare).
10. Débogage et troubleshooting
Section titled â10. DĂ©bogage et troubleshootingâ10.1. ProblĂšmes courants
Section titled â10.1. ProblĂšmes courantsâ| SymptĂŽme | Cause probable | Solution |
|---|---|---|
| Articles non affichés | Collection blog vide | Ajouter des articles dans src/content/blog/ |
| Images non affichées | Images manquantes | Vérifier que les images existent dans src/content/blog/ |
10.2. Logs et monitoring
Section titled â10.2. Logs et monitoringâ# Logs de dĂ©veloppementnpm run dev
# Logs de buildnpm run build -- --verbose
# Vérification des typesnpx astro check10.3. Tests manuels
Section titled â10.3. Tests manuelsâ# Test de la route en localcurl -I http://localhost:4321/blog11. Bonnes pratiques
Section titled â11. Bonnes pratiquesâ11.1. Architecture
Section titled â11.1. Architectureâ- â Utilisation dâAstro content collections pour les articles
- â Tri par date de publication
- â Images optimisĂ©es via Astro Assets
11.2. Performance
Section titled â11.2. Performanceâ- â Pas de JavaScript inutile
- â Images optimisĂ©es (width, height spĂ©cifiĂ©s)
- â SSG pour le rendu statique
11.3. Maintenance
Section titled â11.3. Maintenanceâ- â
Ajouter des articles dans
src/content/blog/ - â VĂ©rifier les images avant publication
12. Ăvolutions et roadmap
Section titled â12. Ăvolutions et roadmapâ12.1. AmĂ©liorations planifiĂ©es
Section titled â12.1. AmĂ©liorations planifiĂ©esâ- Pagination pour les articles
- Filtrage par catégorie
- Indexation Pagefind
- Support du mode preview
12.2. Limitations connues
Section titled â12.2. Limitations connuesâ- â Pas de pagination
- â Pas de filtres
- â Pas de support du mode preview
- â Pas dâindexation Pagefind
- â Langue hardcodĂ©e en âenâ
13. Ressources liées
Section titled â13. Ressources liĂ©esâ- Documentation Astro : Routing
- Documentation Astro : Content Collections
- Fichiers concernés :
src/pages/blog/index.astrosrc/content/blog/src/components/BaseHead.astrosrc/components/Header.astrosrc/components/Footer.astrosrc/components/FormattedDate.astro
14. Historique des modifications
Section titled â14. Historique des modificationsâ| Date | Version | Description | Auteur |
|---|---|---|---|
| 2026-09-15 | 1.0 | Création initiale | Devin |