@bookshop/hugo-engine 3.5.1 → 3.6.0-beta.1

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 (20) hide show
  1. package/.nyc_output/processinfo/{0576b405-4d6f-416a-a012-1cd6714d2de3.json → 96d19458-1b60-4859-b031-8c72da9099fa.json} +1 -1
  2. package/.nyc_output/processinfo/{1186c40f-ab1b-4fc3-8c8f-905478755bdd.json → a648c40e-de2c-4837-b1c6-3f187fd60093.json} +1 -1
  3. package/.nyc_output/processinfo/{9afa86b4-7892-4e9a-b022-45b2ba35af2a.json → a9c10755-e4bf-46a5-8e9f-c8198ddfc209.json} +1 -1
  4. package/.nyc_output/processinfo/aef2ad68-7f2b-4e6e-8583-9c924153a305.json +1 -0
  5. package/.nyc_output/processinfo/{e261f702-c88f-4b27-aebb-f0ddcd3d512e.json → f950cb79-a99a-4f06-a217-fa041433aec7.json} +1 -1
  6. package/.nyc_output/processinfo/index.json +1 -1
  7. package/bookshop-hugo-templates/helpers/component.html +11 -2
  8. package/bookshop-hugo-templates/helpers/flat_component_key.html +9 -0
  9. package/full-hugo-renderer/hugo_renderer.wasm +0 -0
  10. package/full-hugo-renderer/hugo_renderer.wasm.gz +0 -0
  11. package/lib/engine.js +9 -2
  12. package/lib/engine__test__.js +9 -2
  13. package/lib/translateTextTemplate.js +4 -0
  14. package/package.json +2 -2
  15. package/.nyc_output/processinfo/2fdbc94b-8ef1-4abe-8419-3b1f5ae13538.json +0 -1
  16. /package/.nyc_output/{0576b405-4d6f-416a-a012-1cd6714d2de3.json → 96d19458-1b60-4859-b031-8c72da9099fa.json} +0 -0
  17. /package/.nyc_output/{1186c40f-ab1b-4fc3-8c8f-905478755bdd.json → a648c40e-de2c-4837-b1c6-3f187fd60093.json} +0 -0
  18. /package/.nyc_output/{2fdbc94b-8ef1-4abe-8419-3b1f5ae13538.json → a9c10755-e4bf-46a5-8e9f-c8198ddfc209.json} +0 -0
  19. /package/.nyc_output/{9afa86b4-7892-4e9a-b022-45b2ba35af2a.json → aef2ad68-7f2b-4e6e-8583-9c924153a305.json} +0 -0
  20. /package/.nyc_output/{e261f702-c88f-4b27-aebb-f0ddcd3d512e.json → f950cb79-a99a-4f06-a217-fa041433aec7.json} +0 -0
@@ -1 +1 @@
1
- {"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","pid":5527,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1683882586943,"ppid":5494,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/0576b405-4d6f-416a-a012-1cd6714d2de3.json","externalId":"","uuid":"0576b405-4d6f-416a-a012-1cd6714d2de3","files":[]}
1
+ {"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","pid":5755,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1685414618193,"ppid":5714,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/96d19458-1b60-4859-b031-8c72da9099fa.json","externalId":"","uuid":"96d19458-1b60-4859-b031-8c72da9099fa","files":[]}
@@ -1 +1 @@
1
- {"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","pid":5511,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1683882586504,"ppid":5494,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/1186c40f-ab1b-4fc3-8c8f-905478755bdd.json","externalId":"","uuid":"1186c40f-ab1b-4fc3-8c8f-905478755bdd","files":[]}
1
+ {"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","pid":5732,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1685414617697,"ppid":5714,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/a648c40e-de2c-4837-b1c6-3f187fd60093.json","externalId":"","uuid":"a648c40e-de2c-4837-b1c6-3f187fd60093","files":[]}
@@ -1 +1 @@
1
- {"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","pid":5505,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1683882586497,"ppid":5494,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/9afa86b4-7892-4e9a-b022-45b2ba35af2a.json","externalId":"","uuid":"9afa86b4-7892-4e9a-b022-45b2ba35af2a","files":[]}
1
+ {"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","pid":5748,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1685414618152,"ppid":5714,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/a9c10755-e4bf-46a5-8e9f-c8198ddfc209.json","externalId":"","uuid":"a9c10755-e4bf-46a5-8e9f-c8198ddfc209","files":[]}
@@ -0,0 +1 @@
1
+ {"parent":null,"pid":5714,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/cli.js","-v"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1685414617162,"ppid":5703,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/aef2ad68-7f2b-4e6e-8583-9c924153a305.json","externalId":"","uuid":"aef2ad68-7f2b-4e6e-8583-9c924153a305","files":[]}
@@ -1 +1 @@
1
- {"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","pid":5534,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1683882586987,"ppid":5494,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/e261f702-c88f-4b27-aebb-f0ddcd3d512e.json","externalId":"","uuid":"e261f702-c88f-4b27-aebb-f0ddcd3d512e","files":[]}
1
+ {"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","pid":5726,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1685414617687,"ppid":5714,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/f950cb79-a99a-4f06-a217-fa041433aec7.json","externalId":"","uuid":"f950cb79-a99a-4f06-a217-fa041433aec7","files":[]}
@@ -1 +1 @@
1
- {"processes":{"0576b405-4d6f-416a-a012-1cd6714d2de3":{"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","children":[]},"1186c40f-ab1b-4fc3-8c8f-905478755bdd":{"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","children":[]},"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538":{"parent":null,"children":["0576b405-4d6f-416a-a012-1cd6714d2de3","1186c40f-ab1b-4fc3-8c8f-905478755bdd","9afa86b4-7892-4e9a-b022-45b2ba35af2a","e261f702-c88f-4b27-aebb-f0ddcd3d512e"]},"9afa86b4-7892-4e9a-b022-45b2ba35af2a":{"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","children":[]},"e261f702-c88f-4b27-aebb-f0ddcd3d512e":{"parent":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","children":[]}},"files":{},"externalIds":{}}
1
+ {"processes":{"96d19458-1b60-4859-b031-8c72da9099fa":{"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","children":[]},"a648c40e-de2c-4837-b1c6-3f187fd60093":{"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","children":[]},"a9c10755-e4bf-46a5-8e9f-c8198ddfc209":{"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","children":[]},"aef2ad68-7f2b-4e6e-8583-9c924153a305":{"parent":null,"children":["96d19458-1b60-4859-b031-8c72da9099fa","a648c40e-de2c-4837-b1c6-3f187fd60093","a9c10755-e4bf-46a5-8e9f-c8198ddfc209","f950cb79-a99a-4f06-a217-fa041433aec7"]},"f950cb79-a99a-4f06-a217-fa041433aec7":{"parent":"aef2ad68-7f2b-4e6e-8583-9c924153a305","children":[]}},"files":{},"externalIds":{}}
@@ -12,14 +12,23 @@
12
12
  {{- $component_name := index . 0 -}}
13
13
  {{- $component_props := index . 1 -}}
14
14
  {{- $component_path := partial "_bookshop/helpers/component_key" $component_name -}}
15
+ {{- $flat_component_path := partial "_bookshop/helpers/flat_component_key" $component_name -}}
15
16
 
17
+ {{- $resolved_component := false -}}
16
18
  {{- if templates.Exists ( printf "partials/%s" $component_path ) -}}
19
+ {{- $resolved_component = $component_path -}}
20
+ {{- else if templates.Exists ( printf "partials/%s" $flat_component_path ) -}}
21
+ {{- $resolved_component = $flat_component_path -}}
22
+ {{- end -}}
23
+
24
+ {{- if $resolved_component -}}
17
25
 
18
26
  {{/* Suppress comments when live editing {{ (printf "<!--bookshop-live name(%s)-->" $component_name) | safeHTML }} */}}
19
- {{- partial $component_path $component_props -}}
27
+ {{- partial $resolved_component $component_props -}}
20
28
  {{/* Suppress comments when live editing {{ "<!--bookshop-live end-->" | safeHTML }} */}}
21
29
 
22
30
  {{- else -}}
23
31
  {{- $file_loc := slicestr $component_path 9 -}}
24
- {{- partial "_bookshop/errors/err" (printf "Component \"%s\" does not exist.\n Create this component by placing a file in your bookshop at %s" $component_name $file_loc) -}}
32
+ {{- $flat_file_loc := slicestr $flat_component_path 9 -}}
33
+ {{- partial "_bookshop/errors/err" (printf "Component \"%s\" does not exist.\n Create this component by placing a file in your bookshop at %s or %s" $component_name $file_loc $flat_file_loc) -}}
25
34
  {{- end -}}
@@ -0,0 +1,9 @@
1
+ {{/*
2
+ Converts a bare Bookshop component key to a flat Bookshop path
3
+ i.e. "a/b" --> "bookshop/components/a/b.hugo.html"
4
+
5
+ Expects a String.
6
+ */}}
7
+
8
+ {{ $component_path := (printf "bookshop/components/%s.hugo.html" .) }}
9
+ {{ return $component_path }}
package/lib/engine.js CHANGED
@@ -58,6 +58,7 @@ export class Engine {
58
58
  "layouts/partials/bookshop_bindings.html": (await import("../bookshop-hugo-templates/bookshop_bindings.html")).default,
59
59
  "layouts/partials/_bookshop/helpers/component.html": (await import("../bookshop-hugo-templates/helpers/component.html")).default,
60
60
  "layouts/partials/_bookshop/helpers/component_key.html": (await import("../bookshop-hugo-templates/helpers/component_key.html")).default,
61
+ "layouts/partials/_bookshop/helpers/flat_component_key.html": (await import("../bookshop-hugo-templates/helpers/flat_component_key.html")).default,
61
62
  "layouts/partials/_bookshop/helpers/partial.html": (await import("../bookshop-hugo-templates/helpers/partial.html")).default,
62
63
  "layouts/partials/_bookshop/helpers/partial_key.html": (await import("../bookshop-hugo-templates/helpers/partial_key.html")).default,
63
64
  "layouts/partials/_bookshop/errors/bad_bookshop_tag.html": (await import("../bookshop-hugo-templates/errors/bad_bookshop_tag.html")).default,
@@ -156,14 +157,20 @@ export class Engine {
156
157
  return `components/${name}/${base}.hugo.html`;
157
158
  }
158
159
 
160
+ getFlatComponentKey(name) {
161
+ return `components/${name}.hugo.html`;
162
+ }
163
+
159
164
  getComponent(name) {
160
165
  const key = this.getComponentKey(name);
161
- return this.files?.[key];
166
+ const flatKey = this.getFlatComponentKey(name);
167
+ return this.files?.[key] ?? this.files?.[flatKey];
162
168
  }
163
169
 
164
170
  hasComponent(name) {
165
171
  const key = this.getComponentKey(name);
166
- return !!this.files?.[key];
172
+ const flatKey = this.getFlatComponentKey(name);
173
+ return !!(this.files?.[key] ?? this.files?.[flatKey]);
167
174
  }
168
175
 
169
176
  hasShared(name) {
@@ -58,6 +58,7 @@ export class Engine {
58
58
  "layouts/partials/bookshop_bindings.html": (await import("../bookshop-hugo-templates/bookshop_bindings.html")).default,
59
59
  "layouts/partials/_bookshop/helpers/component.html": (await import("../bookshop-hugo-templates/helpers/component.html")).default,
60
60
  "layouts/partials/_bookshop/helpers/component_key.html": (await import("../bookshop-hugo-templates/helpers/component_key.html")).default,
61
+ "layouts/partials/_bookshop/helpers/flat_component_key.html": (await import("../bookshop-hugo-templates/helpers/flat_component_key.html")).default,
61
62
  "layouts/partials/_bookshop/helpers/partial.html": (await import("../bookshop-hugo-templates/helpers/partial.html")).default,
62
63
  "layouts/partials/_bookshop/helpers/partial_key.html": (await import("../bookshop-hugo-templates/helpers/partial_key.html")).default,
63
64
  "layouts/partials/_bookshop/errors/bad_bookshop_tag.html": (await import("../bookshop-hugo-templates/errors/bad_bookshop_tag.html")).default,
@@ -156,14 +157,20 @@ export class Engine {
156
157
  return `components/${name}/${base}.hugo.html`;
157
158
  }
158
159
 
160
+ getFlatComponentKey(name) {
161
+ return `components/${name}.hugo.html`;
162
+ }
163
+
159
164
  getComponent(name) {
160
165
  const key = this.getComponentKey(name);
161
- return this.files?.[key];
166
+ const flatKey = this.getFlatComponentKey(name);
167
+ return this.files?.[key] ?? this.files?.[flatKey];
162
168
  }
163
169
 
164
170
  hasComponent(name) {
165
171
  const key = this.getComponentKey(name);
166
- return !!this.files?.[key];
172
+ const flatKey = this.getFlatComponentKey(name);
173
+ return !!(this.files?.[key] ?? this.files?.[flatKey]);
167
174
  }
168
175
 
169
176
  hasShared(name) {
@@ -124,6 +124,10 @@ export default function (text, opts) {
124
124
  liveMarkup: true,
125
125
  ...opts
126
126
  }
127
+
128
+ // If this component contains no subcomponents,
129
+ // we don't need to add any special comments as there
130
+ // can be no data bindings within.
127
131
  if (!/bookshop/.test(text)) {
128
132
  return text;
129
133
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bookshop/hugo-engine",
3
3
  "packageManager": "yarn@3.0.0",
4
- "version": "3.5.1",
4
+ "version": "3.6.0-beta.1",
5
5
  "description": "Bookshop frontend Hugo renderer",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -31,7 +31,7 @@
31
31
  "nyc": "^15.1.0"
32
32
  },
33
33
  "dependencies": {
34
- "@bookshop/helpers": "3.5.1",
34
+ "@bookshop/helpers": "3.6.0-beta.1",
35
35
  "esbuild": "^0.13.10",
36
36
  "fflate": "^0.7.3",
37
37
  "liquidjs": "9.28.0"
@@ -1 +0,0 @@
1
- {"parent":null,"pid":5494,"argv":["/opt/hostedtoolcache/node/16.20.0/x64/bin/node","/home/runner/work/bookshop/bookshop/javascript-modules/node_modules/ava/cli.js","-v"],"execArgv":[],"cwd":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine","time":1683882585987,"ppid":5483,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/2fdbc94b-8ef1-4abe-8419-3b1f5ae13538.json","externalId":"","uuid":"2fdbc94b-8ef1-4abe-8419-3b1f5ae13538","files":[]}