[RFC] Layout modules
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript, vite
Línea de trabajo
Comienza por relacionar los conceptos existentes de renderizadores y módulos de renderizado con las API propuestas de defineLayout y routes-module, incluido el uso de RenderRequest. Determina cómo encajan la selección del layout, el renderizado de HTML, la hidratación y la configuración de Vite por ruta; se considera terminado cuando el comportamiento del layout y el reemplazo del renderer del RFC estén especificados y sean implementables.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Frontend developers are familiar with the concept of layouts, so let's align with that. This feature would replace the concept of "renderers" and the render module would be no more. At the same time, we'll remove support for having multiple renderers/layouts in one file (which is what the render module encouraged). That feature requires complex parsing of the render module to determine which statements are used by which renderers. It'll be nice to remove that complexity.
How are layouts defined?
Layouts are defined with the defineLayout function and typically exported with export default. Layouts can optionally wrap the defineLayout call with an arrow function so the layout can be customized by the developer for specific routes.
From the routes module, the developer can…
- set the default layout for all routes or a set of routes (via
setLayoutcall) - set the layout of a single route (via chained method call, or maybe the route config?)
What do layouts do?
Layouts control…
- the
<html>and<head>elements (via object or string) - how the route module is rendered to HTML
- how the page is hydrated (if at all)
- the Vite config for each route
Layouts can use the RenderRequest object to influence any of its behavior. Access of route props (via req.props) within the layout's render method is tracked, so only the props needed for hydration are sent to the client. If the layout has no hydrator, then route props are never sent to the client.
Example layout module
export default (options) =>
defineLayout((req) => {
return {
// Can be a string or object.
head: {
title: "",
language: "",
description: "",
viewport: {},
meta: [{ property: "og:title", content: "" }],
styles: [{ media: "", innerText: "" }],
scripts: [{ src: "", async: true }, { innerText: "" }],
links: [{ rel: "icon", href: "/favicon.svg" }],
},
// Provide a Vite config.
config: async () => (await import("./config")).default(options),
// Provide a client hydration function.
hydrator: () => import("./hydrator"),
// Render a route module.
render(module, { nested }) {
// Prop access is observed, so only props needed for hydration are sent to the client.
const layout = <div>{req.props.foo}</div>;
// The `nested` flag tells the layout to skip stringification.
return nested ? layout : renderToHtml(layout);
},
};
});
- Lenguaje dominante
- TypeScript
- Estrellas
- 38
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 alloc/saus
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
package idea
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
Supertokens pluginAbiertohelp wanted package idea
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
-
enhancement plugin:aws saus deploy
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
bug saus deploy
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Todos los issues de alloc/saus
Issues similares
-
area:tui enhancement platform:macos
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
anthropics/claude-code#101490 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
netlify/netlify-mcp#75 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
atlassian-labs/compiled#1960 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
pnp/cli-microsoft365#7639 ·
Los mantenedores suelen responder en 2 días
-
nextjs-tracking
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
cloudflare/vinext#3887 ·
Los mantenedores suelen responder en 1 día