> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wethehivers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Administrer le blog

> Rédiger, publier et modérer les articles du blog

# Administrer le blog

Les admins rédigent, publient et modèrent les articles du blog public `wethehivers.com/blog`.

## Flow global

```mermaid theme={null}
flowchart LR
    A[Admin] --> D[DRAFT]
    D --> ED[Édition markdown]
    ED --> CV[Cover image]
    CV --> SEO[Méta SEO]
    SEO --> PUB[Publier]
    PUB --> PUBLISHED[Article live]
    PUBLISHED --> CDN[Purge CDN + sitemap]
```

## 1. Créer un article (DRAFT)

```http theme={null}
POST /v1/api/admin/blog HTTP/1.1
Authorization: Bearer <ADMIN_TOKEN>
Content-Type: application/json

{
  "titre": "Réussir son entretien Backend Java au Cameroun",
  "resume": "5 conseils d'experts pour briller en entretien...",
  "contenu": "# Introduction\n\nLe marché Java...",
  "categorieId": 3,
  "tags": ["entretien", "java", "backend"],
  "metaTitle": "Entretien Backend Java Cameroun : 5 conseils — THE HIVE",
  "metaDescription": "Comment préparer votre entretien backend..."
}
```

**Réponse** `201` :

```json theme={null}
{
  "id": 14,
  "slug": "reussir-entretien-backend-java-cameroun",
  "status": "DRAFT",
  "createdAt": "2026-04-18T10:00:00Z"
}
```

## 2. Upload de la cover

```http theme={null}
POST /v1/api/admin/blog/14/cover HTTP/1.1
Content-Type: multipart/form-data

file=@cover.jpg
```

```mermaid theme={null}
sequenceDiagram
    participant A as Admin
    participant API as Backend
    participant IMG as Image worker
    participant R2 as R2 public

    A->>API: POST /admin/blog/14/cover (JPG 3000x2000)
    API->>IMG: Optimize WebP + variants (1920, 1200, 600)
    IMG->>R2: PUT public/blog/14/cover.webp\n + responsive variants
    IMG-->>API: keys + dimensions
    API-->>A: 200 {coverImageUrl, variants}
```

## 3. Éditer en markdown

Le champ `contenu` accepte du **markdown** rendu via `remark-gfm`. Supporte :

* Titres `#`, `##`, `###`
* Listes, tableaux, citations
* Liens et images (chemin R2 ou URL externe whitelistée)
* Code blocks avec syntax highlighting
* Embeds YouTube / Twitter via shortcodes

```markdown theme={null}
![Figure 1 : flow recrutement](cover:1200)

:::info
Astuce : préparez 3 projets concrets à raconter.
:::

| Étape | Durée |
|-------|-------|
| Test technique | 1h30 |
| Entretien RH | 30 min |
```

## 4. Publier

```http theme={null}
POST /v1/api/admin/blog/14/publish HTTP/1.1
```

### Validations à la publication

```mermaid theme={null}
flowchart TD
    PUB[publish] --> V1{titre 30-70 car}
    V1 --> V2{metaDescription 50-160 car}
    V2 --> V3{contenu > 300 mots}
    V3 --> V4{cover présente}
    V4 --> V5{slug unique}
    V5 --> V6{catégorie valide}
    V6 --> OK[Publier + publishedAt=NOW]
    OK --> SM[Rebuild sitemap]
    OK --> CDN[Purge CDN /blog/*]
    OK --> PING[Google Indexing API ping]
```

## 5. Dépublier / archiver

```http theme={null}
POST /v1/api/admin/blog/14/unpublish  → retour DRAFT
POST /v1/api/admin/blog/14/archive     → ARCHIVED (hors nav, slug libéré)
```

## 6. Modération des commentaires

```mermaid theme={null}
stateDiagram-v2
    [*] --> PENDING: User poste commentaire
    PENDING --> APPROVED: Admin approve
    PENDING --> REJECTED: Admin reject
    APPROVED --> PENDING: Signalé > 3 fois
    APPROVED --> REJECTED: Admin override
    REJECTED --> [*]
```

```http theme={null}
GET /v1/api/admin/blog/commentaires?status=PENDING

PATCH /v1/api/admin/blog/commentaires/88 { "status": "APPROVED" }
```

### Auto-modération

```mermaid theme={null}
flowchart TD
    NEW[Nouveau commentaire] --> RULE1{Lien externe?}
    RULE1 -->|oui| FLAG[PENDING + flag]
    RULE1 -->|non| RULE2{Injures/spam détectés?}
    RULE2 -->|oui| REJ[REJECTED auto]
    RULE2 -->|non| AUTO_A[APPROVED direct]
```

## 7. Catégories & tags

```http theme={null}
GET /v1/api/admin/blog/categories
POST /v1/api/admin/blog/categories { "nom": "Tech", "slug": "tech", "couleur": "#264194" }
```

Les **tags** sont libres (créés à la volée à la sauvegarde). Les **catégories** sont contrôlées.

## 8. Analytics par article

```http theme={null}
GET /v1/api/admin/blog/14/analytics
```

```json theme={null}
{
  "vuesTotal": 1452,
  "vuesDernieres30j": 312,
  "tempsLectureMoyen": 4.2,
  "tauxSortie": 0.42,
  "commentaires": 8,
  "partages": 24
}
```

```mermaid theme={null}
flowchart LR
    V[Vue] --> TRACK[Track analytics]
    TRACK --> INC[INCR vuesCount]
    TRACK --> TIME[Scroll depth + time on page]
    TIME --> AGG[Agrégation quotidienne]
    AGG --> DASH[Dashboard admin]
```

## 9. SEO & sitemap

```mermaid theme={null}
flowchart TD
    PUB[publish] --> SM[Rebuild /sitemap.xml]
    PUB --> OG[Open Graph metadata]
    PUB --> SD[Schema.org Article JSON-LD]
    PUB --> CDN[Purge Cloudflare]
    PUB --> IDX[Ping Google Indexing API]
```

### Meta-tags générés

```html theme={null}
<title>Entretien Backend Java Cameroun : 5 conseils — THE HIVE</title>
<meta name="description" content="Comment préparer...">
<meta property="og:image" content="https://cdn.wethehivers.com/public/blog/14/cover.webp">
<meta property="og:type" content="article">
<meta name="twitter:card" content="summary_large_image">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Article",...}</script>
```

## 10. Prévisualisation

Chaque DRAFT est accessible via URL privée authentifiée :

```
GET /v1/api/admin/blog/14/preview
→ 200 HTML rendu identique au public
```

## Rôles

| Action                                   | ADMIN | SUPER\_ADMIN |
| ---------------------------------------- | :---: | :----------: |
| Créer / éditer article                   |   ✓   |       ✓      |
| Publier / dépublier                      |   ✓   |       ✓      |
| Modérer commentaires                     |   ✓   |       ✓      |
| Gérer catégories                         |   ✗   |       ✓      |
| Supprimer définitivement article archivé |   ✗   |       ✓      |

## Voir aussi

* [Modèle Blog](/models/blog)
* [Uploads médias](/guides/uploads-medias)
