@static-pages/core 7.0.0-alpha.6 → 7.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Yes! Because I browsed the whole jamstack scene, but could not find one which
|
|
|
17
17
|
|
|
18
18
|
And because I wrote a ton of custom static generators before; I tought I can improve the concepts to a point where its (hopefully) useful for others.
|
|
19
19
|
|
|
20
|
-
This project is structured as a toolkit, published under the [@static-pages](https://www.npmjs.com/search?q=%40static-pages) namespace on NPM.
|
|
20
|
+
This project is structured as a toolkit split to many packages, published under the [@static-pages](https://www.npmjs.com/search?q=%40static-pages) namespace on NPM.
|
|
21
21
|
In most cases you should not use this core package directly, but the [@static-pages/starter](https://www.npmjs.com/package/@static-pages/starter) is a good point to begin with.
|
|
22
22
|
|
|
23
23
|
## Where should I use this?
|
|
@@ -42,22 +42,9 @@ staticPages({
|
|
|
42
42
|
},
|
|
43
43
|
to({ title, url, content, now }) {
|
|
44
44
|
const fileName = path.join('public', url + '.html');
|
|
45
|
+
const fileContent = `<html><body><h1>${title}</h1><p>${content}</p><p>generated: ${now}</p></body></html>`;
|
|
45
46
|
fs.mkdirSync(path.dirname(fileName), { recursive: true });
|
|
46
|
-
fs.writeFileSync(fileName,
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
from: fs.readdir('pages', { recursive: true })
|
|
50
|
-
.map(x => JSON.parse(fs.readFileSync(path.join('pages', x), 'utf8'))),
|
|
51
|
-
controller({ title, url, content }) {
|
|
52
|
-
return {
|
|
53
|
-
url: url,
|
|
54
|
-
content: `<html><body><h1>${title}</h1><p>${content}</p><p>generated: ${new Date().toJSON()}</p></body></html>`,
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
to({ url, content }) {
|
|
58
|
-
const fileName = path.join('public', url + '.html');
|
|
59
|
-
fs.mkdirSync(path.dirname(fileName), { recursive: true });
|
|
60
|
-
fs.writeFileSync(fileName, content);
|
|
47
|
+
fs.writeFileSync(fileName, fileContent);
|
|
61
48
|
}
|
|
62
49
|
})
|
|
63
50
|
.catch(error => {
|
|
@@ -68,8 +55,6 @@ staticPages({
|
|
|
68
55
|
|
|
69
56
|
### Notes
|
|
70
57
|
|
|
71
|
-
> The `controller` may return with multiple documents, each will be rendered as a separate page. Alternatively it may return `undefined` to prevent the rendering of the current document.
|
|
72
|
-
|
|
73
58
|
> The usage example above does a rough presentation only and not considered to be a production ready snippet. Helpers to read and write documents are provided in separate packages, eg. [@static-pages/io](https://www.npmjs.com/package/@static-pages/io).
|
|
74
59
|
|
|
75
60
|
## Documentation
|
|
@@ -88,6 +73,8 @@ interface Route<F, T> {
|
|
|
88
73
|
}
|
|
89
74
|
```
|
|
90
75
|
|
|
76
|
+
The `controller` may return with multiple documents, each will be rendered as a separate page. Alternatively it may return `undefined` to prevent the rendering of the current document.
|
|
77
|
+
|
|
91
78
|
## Missing a feature?
|
|
92
79
|
Create an issue describing your needs!
|
|
93
80
|
If it fits the scope of the project I will implement it.
|