iansinnott / iansinnott/react-static-webpack-plugin

Dynamic Routes

Abierto
#2 9 comentarios 2 reacciones 1 asignado Reclamado por @iansinnott Ver en GitHub
enhancement
Lenguaje dominante
JavaScript
Estrellas
155
Forks
24
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

AKA routes that look like

``` js

```
## The issue

We need dynamic routes to support creating an entire category of sties including blogs. However currently we don't have a way to turn something like `posts/:id` into a file directly. Normally we would have something like this:

```
posts/
hellow-world.md
second-post.md
still-here.md
```

Which would generate the following HTML...

```
posts/
hello-world.html
second-post.html
still-here.html
```

But in our case React Router has no way of knowing the contents of our `posts/` directory so how would it know what files to generate?

Most static site generators would read the `posts/` directory and then generate static sites from those files. However, that requires the user to either learn how to configure their generator or learn the conventions for creating dynamic content.

We could do the same thing:

``` js
fs.readdirSync('./posts').forEach(filename => {
// 1. Read contents of file
// 2. Generate a static HTML file for it
});
```

But then the user would have to know how to hook into this process. It is a first-class goal of this project to not force the user to learn some new technology. Just add this plugin to a webpack config and go. This is the issue I'd like to solve.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.