@paroicms/content-loading-plugin 0.16.1 → 0.18.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.
@@ -1,4 +1,4 @@
1
- import { isDef, strVal } from "@paroi/data-formatters-lib";
1
+ import { isDef, strVal, strValOrUndef } from "@paroi/data-formatters-lib";
2
2
  import { parseNodelId } from "@paroicms/public-anywhere-lib";
3
3
  import { escapeHtml, resolveModuleDirectory, } from "@paroicms/public-server-lib";
4
4
  import { readFileSync } from "node:fs";
@@ -16,20 +16,33 @@ const plugin = {
16
16
  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>`);
17
17
  service.setPublicApiHandler(async (service, httpContext, relativePath) => {
18
18
  const { req, res } = httpContext;
19
- if (relativePath === "/search") {
20
- await makeSearch(service, httpContext, formatSearchTextOptionsInput(req.query));
19
+ if (req.method === "GET" && relativePath === "/search") {
20
+ const input = formatSearchTextOptionsInput(req.query);
21
+ const renderService = await service.openRenderingService({
22
+ language: input.language,
23
+ urlLike: relativePath,
24
+ });
25
+ await makeSearch(renderService, httpContext, input);
26
+ await renderService.close();
21
27
  return;
22
28
  }
23
- if (relativePath === "/partials") {
24
- const labeledById = req.query["labeled-t"];
25
- const fieldName = req.query["labeled-f"];
29
+ if (req.method === "GET" && relativePath === "/partials") {
30
+ const input = formatPartialsQueryInput(req.query);
31
+ const labeledById = strValOrUndef(req.query["labeled-t"]);
32
+ const fieldName = strValOrUndef(req.query["labeled-f"]);
26
33
  const termNodeId = isDef(labeledById) ? toNodeId(labeledById) : undefined;
27
- await getPartials(service, httpContext, formatPartialsQueryInput(req.query), termNodeId !== undefined && fieldName
34
+ const { language } = parseNodelId(input.childrenOf);
35
+ const renderService = await service.openRenderingService({
36
+ language,
37
+ urlLike: relativePath,
38
+ });
39
+ await getPartials(renderService, httpContext, input, termNodeId !== undefined && fieldName
28
40
  ? {
29
41
  fieldName,
30
42
  termNodeId,
31
43
  }
32
44
  : undefined);
45
+ await renderService.close();
33
46
  return;
34
47
  }
35
48
  res.append("Content-Type", "application/json; charset=utf-8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paroicms/content-loading-plugin",
3
- "version": "0.16.1",
3
+ "version": "0.18.0",
4
4
  "description": "Content loading plugin for ParoiCMS",
5
5
  "keywords": [
6
6
  "paroicms",
@@ -33,8 +33,8 @@
33
33
  "@paroicms/public-server-lib": "0"
34
34
  },
35
35
  "devDependencies": {
36
- "@paroicms/public-anywhere-lib": "0.21.1",
37
- "@paroicms/public-server-lib": "0.31.3",
36
+ "@paroicms/public-anywhere-lib": "0.23.0",
37
+ "@paroicms/public-server-lib": "0.34.0",
38
38
  "@paroicms/tiny-modal": "0.5.1",
39
39
  "@solid-primitives/i18n": "~2.2.0",
40
40
  "@solidjs/router": "~0.15.3",