@static-pages/core 7.0.0-alpha.3 → 7.0.0-alpha.4

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.
Files changed (2) hide show
  1. package/README.md +18 -39
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -128,66 +128,35 @@ interface CreateWriterOptions<T> {
128
128
  onError?(error: unknown): MaybePromise<void>;
129
129
  }
130
130
 
131
- interface Stats {
132
- isFile(): boolean;
133
- isDirectory(): boolean;
134
- }
135
-
136
- interface Dirent {
137
- name: string;
138
- path: string;
139
- isFile(): boolean;
140
- isDirectory(): boolean;
141
- }
142
-
143
131
  interface Filesystem {
144
- readdir(
132
+ stat(
145
133
  path: string | URL,
146
- options: {
147
- encoding: 'utf8';
148
- withFileTypes: false;
149
- recursive: boolean;
150
- },
151
- callback: (err: Error | null, files: string[]) => void,
134
+ callback: (err: Error | null, stats: { isFile(): boolean; isDirectory(): boolean; }) => void
152
135
  ): void;
153
136
 
154
137
  readdir(
155
138
  path: string | URL,
156
139
  options: {
157
140
  encoding: 'utf8';
158
- withFileTypes: true;
141
+ withFileTypes: false;
159
142
  recursive: boolean;
160
143
  },
161
- callback: (err: Error | null, files: Dirent[]) => void,
144
+ callback: (err: Error | null, files: string[]) => void,
162
145
  ): void;
163
146
 
164
- readFile(
147
+ mkdir(
165
148
  path: string | URL,
166
149
  options: {
167
- encoding: 'utf8';
150
+ recursive: true;
168
151
  },
169
- callback: (err: Error | null, data: string) => void
152
+ callback: (err: Error | null, path?: string) => void
170
153
  ): void;
171
154
 
172
155
  readFile(
173
156
  path: string | URL,
174
- options: null,
175
157
  callback: (err: Error | null, data: Uint8Array) => void
176
158
  ): void;
177
159
 
178
- stat(
179
- path: string | URL,
180
- callback: (err: Error | null, stats: Stats) => void
181
- ): void;
182
-
183
- mkdir(
184
- path: string | URL,
185
- options: {
186
- recursive: true;
187
- },
188
- callback: (err: Error | null, path?: string) => void
189
- ): void;
190
-
191
160
  writeFile(
192
161
  path: string | URL,
193
162
  data: string | Uint8Array,
@@ -203,7 +172,7 @@ When you use the `createReader` and `createWriter` interfaces to read and write
203
172
  ### `CreateReaderOptions` default parameters
204
173
  - `fs`: the nodejs `fs` module
205
174
  - `cwd`: `'pages'`
206
- - `parse`: automatically parse `json`, `yaml`, `yml`, `md` or `markdown` extensions with `yaml` and `gray-matter` packages.
175
+ - `parse`: *see About the default `parse` function*
207
176
  - `onError`: `(err) => { throw err; }`
208
177
 
209
178
  ### `CreateWriterOptions` default parameters
@@ -213,6 +182,16 @@ When you use the `createReader` and `createWriter` interfaces to read and write
213
182
  - `render`: `(data) => data.content`
214
183
  - `onError`: `(err) => { throw err; }`
215
184
 
185
+ ### About the default `parse` function
186
+
187
+ When using the default parser, a file type will be guessed by the file extension.
188
+ These could be `json`, `yaml`, `yml`, `md` or `markdown`.
189
+ - `json` will be parsed with `JSON.parse`
190
+ - `yaml` and `yml` will be parsed with the `yaml` package
191
+ - `md` and `markdown` will be parsed with the `gray-matter` package
192
+
193
+ When the document does not contain an `url` property, this function will create one containing the filename without extension.
194
+
216
195
 
217
196
  ## `staticPages.with(defaults: Partial<Route>): { (...routes: Partial<Route>[]): Promise<void>; }`
218
197
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@static-pages/core",
3
- "version": "7.0.0-alpha.3",
3
+ "version": "7.0.0-alpha.4",
4
4
  "description": "General purpose static pages renderer.",
5
5
  "type": "module",
6
6
  "main": "cjs/index.js",