@paroicms/content-loading-plugin 0.10.0 → 0.11.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/backend/dist/controller.js +8 -13
- package/backend/dist/plugin.js +13 -14
- package/package.json +5 -4
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.getPartials = getPartials;
|
|
5
|
-
exports.toNodeId = toNodeId;
|
|
6
|
-
const data_formatters_lib_1 = require("@paroi/data-formatters-lib");
|
|
7
|
-
const public_anywhere_lib_1 = require("@paroicms/public-anywhere-lib");
|
|
8
|
-
async function makeSearch(service, query, req, res) {
|
|
1
|
+
import { isDef } from "@paroi/data-formatters-lib";
|
|
2
|
+
import { parseNodelId } from "@paroicms/public-anywhere-lib";
|
|
3
|
+
export async function makeSearch(service, query, req, res) {
|
|
9
4
|
const { q, language, limit, start, tpl } = query;
|
|
10
5
|
const words = q.split(/\s+/).filter((word) => word.length >= 2);
|
|
11
6
|
if (words.length === 0)
|
|
@@ -20,10 +15,10 @@ async function makeSearch(service, query, req, res) {
|
|
|
20
15
|
templateName: tpl,
|
|
21
16
|
});
|
|
22
17
|
}
|
|
23
|
-
async function getPartials(service, req, res, params, labeledById) {
|
|
18
|
+
export async function getPartials(service, req, res, params, labeledById) {
|
|
24
19
|
const documentId = params["children-of"];
|
|
25
|
-
const parentId =
|
|
26
|
-
const labeledByTermId =
|
|
20
|
+
const parentId = parseNodelId(documentId);
|
|
21
|
+
const labeledByTermId = isDef(labeledById) ? toNodeId(labeledById) : undefined;
|
|
27
22
|
const payload = {
|
|
28
23
|
templateName: params.templateName,
|
|
29
24
|
documentId,
|
|
@@ -38,6 +33,6 @@ async function getPartials(service, req, res, params, labeledById) {
|
|
|
38
33
|
labeledByTermId,
|
|
39
34
|
});
|
|
40
35
|
}
|
|
41
|
-
function toNodeId(nodeOrNodelId) {
|
|
42
|
-
return nodeOrNodelId.indexOf(":") !== -1 ?
|
|
36
|
+
export function toNodeId(nodeOrNodelId) {
|
|
37
|
+
return nodeOrNodelId.indexOf(":") !== -1 ? parseNodelId(nodeOrNodelId).nodeId : nodeOrNodelId;
|
|
43
38
|
}
|
package/backend/dist/plugin.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const version = (0, data_formatters_lib_1.strVal)(require((0, node_path_1.join)(packageDir, "package.json")).version);
|
|
1
|
+
import { strVal } from "@paroi/data-formatters-lib";
|
|
2
|
+
import { escapeHtml, resolveModuleDirectory, } from "@paroicms/public-server-lib";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { getPartials, makeSearch } from "./controller.js";
|
|
6
|
+
const projectDir = resolveModuleDirectory(import.meta.url, { parent: true });
|
|
7
|
+
const packageDir = dirname(projectDir);
|
|
8
|
+
const version = strVal(JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8")).version);
|
|
10
9
|
const plugin = {
|
|
11
10
|
version,
|
|
12
11
|
slug: "content-loading",
|
|
13
12
|
async siteInit(service) {
|
|
14
|
-
service.setPublicAssetsDirectory(
|
|
15
|
-
service.addHeadTag(`<link rel="stylesheet" href="${
|
|
13
|
+
service.setPublicAssetsDirectory(join(packageDir, "public-front", "dist"));
|
|
14
|
+
service.addHeadTag(`<link rel="stylesheet" href="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.css`)}">`, `<script type="module" src="${escapeHtml(`${service.pluginAssetsUrl}/public-front-plugin.mjs`)}"></script>`);
|
|
16
15
|
service.setPublicApiHandler(async (ctx, req, res, relativePath) => {
|
|
17
16
|
if (relativePath === "/search") {
|
|
18
|
-
await
|
|
17
|
+
await makeSearch(ctx, req.query, req, res);
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
if (relativePath === "/partials") {
|
|
22
21
|
const labeledById = req.query.labeledById;
|
|
23
|
-
await
|
|
22
|
+
await getPartials(ctx, req, res, req.query, labeledById);
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
res.append("Content-Type", "application/json; charset=utf-8");
|
|
@@ -29,4 +28,4 @@ const plugin = {
|
|
|
29
28
|
});
|
|
30
29
|
},
|
|
31
30
|
};
|
|
32
|
-
|
|
31
|
+
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/content-loading-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Content loading plugin for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"@paroicms/public-server-lib": "0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@paroicms/public-anywhere-lib": "0.
|
|
36
|
-
"@paroicms/public-server-lib": "0.
|
|
37
|
-
"@paroicms/tiny-modal": "0.
|
|
35
|
+
"@paroicms/public-anywhere-lib": "0.15.0",
|
|
36
|
+
"@paroicms/public-server-lib": "0.23.0",
|
|
37
|
+
"@paroicms/tiny-modal": "0.2.0",
|
|
38
38
|
"@solid-primitives/i18n": "~2.1.1",
|
|
39
39
|
"@solidjs/router": "~0.14.1",
|
|
40
40
|
"@types/node": "~22.10.7",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"vite-plugin-solid": "~2.11.0",
|
|
48
48
|
"terser": "~5.37.0"
|
|
49
49
|
},
|
|
50
|
+
"type": "module",
|
|
50
51
|
"main": "backend/dist/plugin.js",
|
|
51
52
|
"files": [
|
|
52
53
|
"backend/dist",
|