iansinnott / iansinnott/react-static-webpack-plugin

Dynamic Routes

Aperta
#2 9 commenti 2 reazioni 1 assegnatario Rivendicata da @iansinnott Vedi su GitHub
enhancement
Lingua principale
JavaScript
Stelle
155
Fork
24
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.