@sphido/core 2.0.6 → 2.0.9

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/lib/all-pages.js CHANGED
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Page generator that flatten pages structure
3
+ *
4
+ * @generator
3
5
  * @param {array} pages
6
+ * @yields {name:string, path:string} next page in pages list
4
7
  */
5
8
  export function * allPages(pages) {
6
9
  for (const page of pages) {
package/lib/copy-file.js CHANGED
@@ -5,8 +5,8 @@ import {dirname} from 'node:path';
5
5
  /**
6
6
  * Write content to the file and create directory if not exists
7
7
  *
8
- * @param {string} file
9
- * @param {string} content
8
+ * @param {string} src
9
+ * @param {string} dest
10
10
  * @returns {Promise<*>}
11
11
  */
12
12
  export async function copyFile(src, dest) {
package/lib/get-pages.js CHANGED
@@ -5,9 +5,9 @@ import {isPage} from './is-page.js';
5
5
  /**
6
6
  * Retrieve an array tree of pages from path
7
7
  * @param {string} path
8
- * @param {Function} include
9
- * @param extenders
10
- * @returns {Promise<Awaited<unknown>[{name, path}]>}
8
+ * @param {function(dirent:Dirent, path:string)} include
9
+ * @param {Object|function(page:{name:string, path:string}, dirent:Dirent, path:string)} extenders
10
+ * @returns {Promise<Awaited<unknown>[{name:string, path:string}]>}
11
11
  */
12
12
  export async function getPages({path = 'content', include = isPage} = {}, ...extenders) {
13
13
  const dir = await readdir(path, {withFileTypes: true});
@@ -24,8 +24,10 @@ export async function getPages({path = 'content', include = isPage} = {}, ...ext
24
24
  page.children = await getPages({path: page.path, include}, ...extenders);
25
25
  }
26
26
 
27
- // Calling callbacks
28
- await Promise.all(extenders.filter(f => typeof f === 'function').map(f => f(page, dirent, path)));
27
+ // Calling callbacks in the series
28
+ for (const cb of extenders.filter(f => typeof f === 'function')) {
29
+ await cb(page, dirent, path);
30
+ }
29
31
 
30
32
  // Assign objects with page
31
33
  return Object.assign(page, ...extenders.filter(o => typeof o === 'object'));
package/lib/is-page.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * - skip drafts files with underscore at the beginning
7
7
  * - accept only *.html and *.md files
8
8
  *
9
- * @param {object} dirent
9
+ * @param {Dirent} dirent
10
10
  * @returns {boolean}
11
11
  */
12
12
  export function isPage(dirent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphido/core",
3
- "version": "2.0.6",
3
+ "version": "2.0.9",
4
4
  "author": {
5
5
  "name": "Roman Ožana",
6
6
  "email": "roman@ozana.cz",
@@ -45,5 +45,5 @@
45
45
  "no-await-in-loop": 0
46
46
  }
47
47
  },
48
- "gitHead": "0da6b1833720df984911fdf6d560a82022a15407"
48
+ "gitHead": "5ede811c6442f334f5dd04f0d146b49fc7a785ad"
49
49
  }
package/readme.md CHANGED
@@ -153,4 +153,4 @@ for (const page of allPages(pages)) {
153
153
 
154
154
  ## Source codes
155
155
 
156
- https://github.com/sphido/sphido/tree/main/packages/sphido-core
156
+ [@sphido/core](https://github.com/sphido/sphido/tree/main/packages/sphido-core