@sleetch/server 1.0.7 → 1.0.8

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 (3) hide show
  1. package/dist/index.d.ts +14 -14
  2. package/dist/index.js +26 -26
  3. package/package.json +26 -26
package/dist/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import { partial_sleetch_configuration as sleetch_configuration, path_transformer } from "@sleetch/core/configuration";
2
+ //#region src/utils/llms.d.ts
3
+ declare function get_llms(transformer: path_transformer<string>): Promise<string>;
4
+ //#endregion
2
5
  //#region src/utils/pages.d.ts
3
6
  declare const get_page: (_path: string, _language?: string) => Promise<{
4
7
  language: string;
@@ -20,6 +23,17 @@ declare const get_pages: (_language?: string) => Promise<{
20
23
  }[];
21
24
  }>;
22
25
  //#endregion
26
+ //#region src/utils/rss.d.ts
27
+ declare function get_rss({ site, title, description, transformer }: {
28
+ site: string;
29
+ title: string;
30
+ description: string;
31
+ transformer: path_transformer<string>;
32
+ }): Promise<string>;
33
+ //#endregion
34
+ //#region src/utils/sitemap.d.ts
35
+ declare function get_sitemap(path_builder: path_transformer): Promise<string>;
36
+ //#endregion
23
37
  //#region src/utils/tree.d.ts
24
38
  declare const get_tree: (_language?: string) => Promise<{
25
39
  tree: import("@sleetch/core/compiler").tree_object[];
@@ -30,18 +44,4 @@ declare const get_static_paths: <T>(transformer: path_transformer<T>, _language?
30
44
  language: string;
31
45
  }>;
32
46
  //#endregion
33
- //#region src/utils/sitemap.d.ts
34
- declare function get_sitemap(path_builder: path_transformer): Promise<string>;
35
- //#endregion
36
- //#region src/utils/llms.d.ts
37
- declare function get_llms(transformer: path_transformer<string>): Promise<string>;
38
- //#endregion
39
- //#region src/utils/rss.d.ts
40
- declare function get_rss({ site, title, description, transformer }: {
41
- site: string;
42
- title: string;
43
- description: string;
44
- transformer: path_transformer<string>;
45
- }): Promise<string>;
46
- //#endregion
47
47
  export { get_llms, get_page, get_pages, get_rss, get_sitemap, get_static_paths, get_tree, type sleetch_configuration };
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import { resolve_language, to_flat_tree } from "@sleetch/core/compiler";
2
2
  //#region src/utils/tree.ts
3
3
  const get_tree = async (_language) => {
4
4
  const language = resolve_language(_language);
5
- const { default: manifest } = await import("@sleetch/client/manifest.js");
6
- const { default: tree } = await manifest[language]["tree"]();
5
+ const { default: manifest } = await import("@sleetch/client/manifest");
6
+ const { default: tree } = await manifest[language].tree();
7
7
  return {
8
8
  tree,
9
9
  language
@@ -20,19 +20,19 @@ const get_static_paths = async (transformer, _language) => {
20
20
  };
21
21
  };
22
22
  const get_languages = async () => {
23
- const { default: manifest } = await import("@sleetch/client/manifest.js");
23
+ const { default: manifest } = await import("@sleetch/client/manifest");
24
24
  return manifest.languages;
25
25
  };
26
26
  //#endregion
27
27
  //#region src/utils/pages.ts
28
28
  const get_page = async (_path, _language) => {
29
- if (_path.length == 0) _path = "/";
30
- else if (!_path.startsWith("/", 0)) _path = "/" + _path;
31
- if (_path.length > 1 && _path.slice(-1) == "/") _path = _path.slice(0, -1);
29
+ if (_path.length === 0) _path = "/";
30
+ else if (!_path.startsWith("/", 0)) _path = `/${_path}`;
31
+ if (_path.length > 1 && _path.slice(-1) === "/") _path = _path.slice(0, -1);
32
32
  const language = resolve_language(_language);
33
- const { default: manifest } = await import("@sleetch/client/manifest.js");
34
- for (const path of Object.keys(manifest[language]["pages"])) if (path == _path) {
35
- const { default: page } = await manifest[language]["pages"][path]();
33
+ const { default: manifest } = await import("@sleetch/client/manifest");
34
+ for (const path of Object.keys(manifest[language].pages)) if (path === _path) {
35
+ const { default: page } = await manifest[language].pages[path]();
36
36
  return {
37
37
  language,
38
38
  path,
@@ -47,26 +47,10 @@ const get_pages = async (_language) => {
47
47
  const { language, paths } = await get_static_paths(async ({ path, language }) => await get_page(path, language), _language);
48
48
  return {
49
49
  language,
50
- pages: (await Promise.all(paths)).filter((x) => x != void 0)
50
+ pages: (await Promise.all(paths)).filter((x) => x !== void 0)
51
51
  };
52
52
  };
53
53
  //#endregion
54
- //#region src/utils/sitemap.ts
55
- async function get_sitemap(path_builder) {
56
- const languages = await get_languages();
57
- const urls = [];
58
- for (const language of languages) {
59
- const { paths } = await get_static_paths(path_builder, language);
60
- for (const path of paths) urls.push(`<url>
61
- <loc>${path}</loc>
62
- </url>`);
63
- }
64
- return `<?xml version="1.0" encoding="UTF-8"?>
65
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
66
- ${urls.join("\n ")}
67
- </urlset>`;
68
- }
69
- //#endregion
70
54
  //#region src/utils/llms.ts
71
55
  async function get_llms(transformer) {
72
56
  const languages = await get_languages();
@@ -118,4 +102,20 @@ async function get_rss({ site, title, description, transformer }) {
118
102
  </rss>`;
119
103
  }
120
104
  //#endregion
105
+ //#region src/utils/sitemap.ts
106
+ async function get_sitemap(path_builder) {
107
+ const languages = await get_languages();
108
+ const urls = [];
109
+ for (const language of languages) {
110
+ const { paths } = await get_static_paths(path_builder, language);
111
+ for (const path of paths) urls.push(`<url>
112
+ <loc>${path}</loc>
113
+ </url>`);
114
+ }
115
+ return `<?xml version="1.0" encoding="UTF-8"?>
116
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
117
+ ${urls.join("\n ")}
118
+ </urlset>`;
119
+ }
120
+ //#endregion
121
121
  export { get_llms, get_page, get_pages, get_rss, get_sitemap, get_static_paths, get_tree };
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
- "name": "@sleetch/server",
3
- "version": "1.0.7",
4
- "type": "module",
5
- "files": [
6
- "dist"
7
- ],
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "scripts": {
12
- "build": "tsdown",
13
- "dev": "tsdown --watch"
14
- },
15
- "dependencies": {
16
- "@sleetch/core": "1.0.7"
17
- },
18
- "peerDependencies": {
19
- "@sleetch/client": "1.0.7"
20
- },
21
- "exports": {
22
- ".": "./dist/index.js",
23
- "./package.json": "./package.json"
24
- },
25
- "types": "./dist/index.d.ts",
26
- "main": "./dist/index.js",
27
- "module": "./dist/index.js"
2
+ "name": "@sleetch/server",
3
+ "version": "1.0.8",
4
+ "type": "module",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "scripts": {
12
+ "build": "tsdown",
13
+ "dev": "tsdown --watch"
14
+ },
15
+ "dependencies": {
16
+ "@sleetch/core": "1.0.8"
17
+ },
18
+ "peerDependencies": {
19
+ "@sleetch/client": "1.0.8"
20
+ },
21
+ "exports": {
22
+ ".": "./dist/index.js",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "types": "./dist/index.d.ts",
26
+ "main": "./dist/index.js",
27
+ "module": "./dist/index.js"
28
28
  }