docs(adr): ADR-0002: Dual Output Mode (Full Pages + Fragments)
@aRustyDev ya está trabajando en esto.
Desde el 5/1/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
ADR-0002: Dual Output Mode (Full Pages + Fragments)
Status
Accepted
Context
HTMX-based applications require two types of responses:
- Full page - Initial load or non-HTMX clients (includes
<html>,<head>, layout) - Fragment - HTMX requests with
HX-Request: trueheader (content only)
The backend must decide how to generate these outputs.
Decision Drivers
- Server Simplicity - Minimize runtime logic in serving layer
- Cache Efficiency - Static files can be cached at CDN edge
- Flexibility - Support different deployment models
- Build Performance - Avoid excessive output duplication
Options Considered
Option A: Single Output, Runtime Detection
Generate only full pages; server strips layout at runtime.
book/htmx/
└── pages/
└── chapter-1.html # Full page only
Server uses HTML parsing (lol_html, cheerio) to extract <main> content.
Pros:
- Smaller build output
- Single source of truth
Cons:
- Runtime overhead on every HTMX request
- Requires HTML parser in server
- Complex edge caching (Vary header needed)
Option B: Fragment-Only Output
Generate only fragments; server wraps in layout at runtime.
book/htmx/
└── fragments/
└── chapter-1.html # Content only
Server composes full pages by injecting fragment into layout.
Pros:
- Smallest build output
- DRY templates
Cons:
- Full page requests require runtime composition
- Layout changes require server restart
- Less cacheable
Option C: Dual Output (Recommended)
Generate both full pages and fragments at build time.
book/htmx/
├── pages/
│ └── chapter-1.html # Full page (layout + content)
└── fragments/
└── chapter-1.html # Content only
Server selects file based on HX-Request header.
Pros:
- Zero runtime overhead (file selection only)
- Full CDN cacheability
- Works with static file servers
- Progressive enhancement (works without JS)
Cons:
- ~2x output size
- Build-time layout changes require rebuild
Option D: Configurable Mode
Let user choose via config:
[output.htmx]
output-mode = "full" | "fragments" | "both"
Pros:
- Maximum flexibility
- Users optimize for their deployment
Cons:
- More complex documentation
- Testing burden
Decision
Implement dual output as default, with configurable output-mode.
Default: output-mode = "both"
Rationale:
- Zero runtime overhead is critical for edge deployments (Cloudflare Workers)
- Static file selection (
HX-Request→ fragments/, else → pages/) is trivial - Storage is cheap; compute at edge is not
- Progressive enhancement requires full pages for initial load
- Config option satisfies users with specific constraints
Implementation
enum OutputMode {
Full, // Only pages/
Fragments, // Only fragments/
Both, // Both directories (default)
}
fn render_chapter(&self, chapter: &Chapter, mode: OutputMode) {
match mode {
OutputMode::Full | OutputMode::Both => {
write_file(pages_dir.join(&chapter.path), render_full(chapter));
}
OutputMode::Fragments | OutputMode::Both => {
write_file(fragments_dir.join(&chapter.path), render_fragment(chapter));
}
}
}
Consequences
Positive
- Simple server logic (file routing only)
- CDN-friendly (static files, no Vary complexity)
- Works with any static file server
- Progressive enhancement out of the box
Negative
- Larger build output (~2x for
bothmode) - Layout changes require full rebuild
Mitigation
- Document
output-mode = "fragments"for dynamic server deployments - Implement incremental builds (only changed chapters)
References
- Lenguaje dominante
- Rust
- Estrellas
- 0
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de aRustyDev/mdbook-htmx
-
feat(ci): Implement cross-repo-validate compliance for docs syncQuizá libre de nuevo @aRustyDev la tomó hace 286 días y no hay ningún pull request abierto. Abiertoci enhancement
aRustyDev/mdbook-htmx#58 · 1 comentario · 1 asignado ·
-
docs(htmx): Explain how HTMX worksQuizá libre de nuevo @aRustyDev la tomó hace 289 días y no hay ningún pull request abierto. Abierto
aRustyDev/mdbook-htmx#48 · 3 comentarios · 1 asignado ·
-
docs(mdbook-htmx): Parent Issue for documentationQuizá libre de nuevo @aRustyDev la tomó hace 289 días y no hay ningún pull request abierto. Abiertodocumentation
aRustyDev/mdbook-htmx#47 · 1 asignado ·
-
docs(examples): Secure Self-Hosted Meilisearch via CloudflareQuizá libre de nuevo @aRustyDev la tomó hace 289 días y no hay ningún pull request abierto. Abiertodocumentation
aRustyDev/mdbook-htmx#46 · 1 asignado ·
-
docs(examples): Kubernetes with MeilisearchQuizá libre de nuevo @aRustyDev la tomó hace 289 días y no hay ningún pull request abierto. Abiertodocumentation
aRustyDev/mdbook-htmx#45 · 1 asignado ·
Todos los issues de aRustyDev/mdbook-htmx
Issues similares
-
area: config effort: S good first issue P3 type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
ferenyl/azuredevopstui#63 ·
-
needs-triage O-Arm T-libs
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
bug CLI config mcp
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
documentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
yunaremaia/sandbox-ffi-layers#56 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
git-ai-project/git-ai#2434 ·
Los mantenedores suelen responder en 1 día