@sphido/core 2.0.15 → 2.0.17
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/LICENSE +21 -0
- package/lib/all-pages.js +2 -3
- package/lib/get-pages.js +25 -4
- package/lib/is-page.js +1 -1
- package/package.json +52 -47
- package/types/all-pages.d.ts +7 -0
- package/types/copy-file.d.ts +8 -0
- package/types/get-pages.d.ts +21 -0
- package/types/index.d.ts +5 -0
- package/types/is-page.d.ts +12 -0
- package/types/read-file.d.ts +6 -0
- package/types/write-file.d.ts +8 -0
- package/LICENSE.md +0 -24
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Roman Ožana (https://ozana.cz/)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/lib/all-pages.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Page generator that flatten pages structure
|
|
3
3
|
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
6
|
-
* @yields {name:string, path:string} next page in pages list
|
|
4
|
+
* @param {import('get-pages.js').Pages} pages
|
|
5
|
+
* @return {import('get-pages.js').Page}
|
|
7
6
|
*/
|
|
8
7
|
export function * allPages(pages) {
|
|
9
8
|
for (const page of pages) {
|
package/lib/get-pages.js
CHANGED
|
@@ -4,10 +4,10 @@ import {isPage} from './is-page.js';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Retrieve an array tree of pages from path
|
|
7
|
-
*
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @
|
|
7
|
+
*
|
|
8
|
+
* @param {Options}
|
|
9
|
+
* @param {Extenders} extenders
|
|
10
|
+
* @return {Promise<Awaited<Pages>[]>}
|
|
11
11
|
*/
|
|
12
12
|
export async function getPages({path = 'content', include = isPage} = {}, ...extenders) {
|
|
13
13
|
const dir = await readdir(path, {withFileTypes: true});
|
|
@@ -26,6 +26,7 @@ export async function getPages({path = 'content', include = isPage} = {}, ...ext
|
|
|
26
26
|
|
|
27
27
|
// Calling callbacks in the series
|
|
28
28
|
for (const cb of extenders.filter(f => typeof f === 'function')) {
|
|
29
|
+
/** @type {ExtenderCallback} */
|
|
29
30
|
await cb(page, dirent, path);
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -33,3 +34,23 @@ export async function getPages({path = 'content', include = isPage} = {}, ...ext
|
|
|
33
34
|
return Object.assign(page, ...extenders.filter(o => typeof o === 'object'));
|
|
34
35
|
}));
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {Array.<Object|ExtenderCallback>} Extenders
|
|
40
|
+
* @typedef {Array.<Page>} Pages
|
|
41
|
+
* @typedef {{name: string, path: string, children?: Pages}} Page
|
|
42
|
+
* @typedef {{path: string, include?: IncludePage}} Options
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @callback ExtenderCallback
|
|
47
|
+
* @param {Page} page
|
|
48
|
+
* @param {import('node:fs').Dirent} dirent
|
|
49
|
+
* @param {string=} path
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @callback IncludePage
|
|
54
|
+
* @param {import('node:fs').Dirent} dirent
|
|
55
|
+
* @param {string=} path
|
|
56
|
+
*/
|
package/lib/is-page.js
CHANGED
package/package.json
CHANGED
|
@@ -1,49 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@sphido/core",
|
|
3
|
+
"version": "2.0.17",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Roman Ožana",
|
|
6
|
+
"email": "roman@ozana.cz",
|
|
7
|
+
"url": "https://ozana.cz"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"description": "A rocket 🚀 fast, lightweight, static site generator",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": "./lib/index.js",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=16"
|
|
15
|
+
},
|
|
16
|
+
"types": "types/index.d.ts",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"markdown",
|
|
19
|
+
"markup",
|
|
20
|
+
"content management system",
|
|
21
|
+
"cms",
|
|
22
|
+
"static",
|
|
23
|
+
"static site generator",
|
|
24
|
+
"generator",
|
|
25
|
+
"framework",
|
|
26
|
+
"numjucks",
|
|
27
|
+
"blog",
|
|
28
|
+
"scaffold"
|
|
29
|
+
],
|
|
30
|
+
"homepage": "https://sphido.org",
|
|
31
|
+
"bugs": "https://github.com/sphido/sphido/issues",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git@github.com:sphido/sphido.git"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@sindresorhus/slugify": "^2.2.0",
|
|
38
|
+
"ava": "^5.2.0",
|
|
39
|
+
"marked": "^4.2.12"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "ava",
|
|
43
|
+
"types": "tsc lib/*.js --declaration --allowJs --emitDeclarationOnly --outDir types"
|
|
44
|
+
},
|
|
45
|
+
"xo": {
|
|
46
|
+
"ignores": [
|
|
47
|
+
"types/**"
|
|
48
|
+
],
|
|
49
|
+
"rules": {
|
|
50
|
+
"no-await-in-loop": 0
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "6d977aa261aecb80b4221c9af8ff61e8756a9456"
|
|
49
54
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve an array tree of pages from path
|
|
3
|
+
*
|
|
4
|
+
* @param {Options}
|
|
5
|
+
* @param {Extenders} extenders
|
|
6
|
+
* @return {Promise<Awaited<Pages>[]>}
|
|
7
|
+
*/
|
|
8
|
+
export function getPages({ path, include }?: Options, ...extenders: Extenders): Promise<Awaited<Pages>[]>;
|
|
9
|
+
export type Extenders = Array<any | ExtenderCallback>;
|
|
10
|
+
export type Pages = Array<Page>;
|
|
11
|
+
export type Page = {
|
|
12
|
+
name: string;
|
|
13
|
+
path: string;
|
|
14
|
+
children?: Page[];
|
|
15
|
+
};
|
|
16
|
+
export type Options = {
|
|
17
|
+
path: string;
|
|
18
|
+
include?: IncludePage;
|
|
19
|
+
};
|
|
20
|
+
export type ExtenderCallback = (page: Page, dirent: import('node:fs').Dirent, path?: string | undefined) => any;
|
|
21
|
+
export type IncludePage = (dirent: import('node:fs').Dirent, path?: string | undefined) => any;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default page filter
|
|
3
|
+
*
|
|
4
|
+
* - skip hidden files (starts with .)
|
|
5
|
+
* - skip and directories (starts with .)
|
|
6
|
+
* - skip drafts files with underscore at the beginning
|
|
7
|
+
* - accept only *.html and *.md files
|
|
8
|
+
*
|
|
9
|
+
* @param {import('node:fs').Dirent} dirent
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
12
|
+
export function isPage(dirent: import('node:fs').Dirent): boolean;
|
package/LICENSE.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
-----------
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2022 Roman Ožana (https://ozana.cz/)
|
|
5
|
-
Permission is hereby granted, free of charge, to any person
|
|
6
|
-
obtaining a copy of this software and associated documentation
|
|
7
|
-
files (the "Software"), to deal in the Software without
|
|
8
|
-
restriction, including without limitation the rights to use,
|
|
9
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the
|
|
11
|
-
Software is furnished to do so, subject to the following
|
|
12
|
-
conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be
|
|
15
|
-
included in all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
-
OTHER DEALINGS IN THE SOFTWARE.
|