@bookshop/hugo-engine 3.3.3 → 3.4.0-alpha.2
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/.nyc_output/{25f8c04a-7fe3-4d10-b99e-0688e18203ec.json → 0f70a16f-6a79-48c7-8b16-3b4665e247b2.json} +0 -0
- package/.nyc_output/{2c3e7d19-6b44-48be-857a-ceba6bb9bf99.json → 6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json} +0 -0
- package/.nyc_output/{5429d932-0ea0-4757-b731-0a647f4adc5f.json → 8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json} +0 -0
- package/.nyc_output/{723f5a1e-49f4-48c2-8a96-069bb758bb7f.json → c5490eb0-70c0-468f-a43f-e58c75dd34c8.json} +0 -0
- package/.nyc_output/{e4df4511-7e66-4fa6-84ed-6bd96e3027fe.json → ee1a9bec-d318-4aea-af93-7269debcf6df.json} +0 -0
- package/.nyc_output/processinfo/{25f8c04a-7fe3-4d10-b99e-0688e18203ec.json → 0f70a16f-6a79-48c7-8b16-3b4665e247b2.json} +1 -1
- package/.nyc_output/processinfo/6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json +1 -0
- package/.nyc_output/processinfo/{2c3e7d19-6b44-48be-857a-ceba6bb9bf99.json → 8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json} +1 -1
- package/.nyc_output/processinfo/{5429d932-0ea0-4757-b731-0a647f4adc5f.json → c5490eb0-70c0-468f-a43f-e58c75dd34c8.json} +1 -1
- package/.nyc_output/processinfo/{723f5a1e-49f4-48c2-8a96-069bb758bb7f.json → ee1a9bec-d318-4aea-af93-7269debcf6df.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/bookshop-hugo-templates/bookshop.html +56 -0
- package/bookshop-hugo-templates/bookshop_bindings.html +29 -0
- package/bookshop-hugo-templates/bookshop_component_browser.html +30 -0
- package/bookshop-hugo-templates/bookshop_partial.html +42 -0
- package/bookshop-hugo-templates/bookshop_scss.html +9 -0
- package/bookshop-hugo-templates/errors/bad_bookshop_tag.html +39 -0
- package/bookshop-hugo-templates/errors/err.html +6 -0
- package/bookshop-hugo-templates/helpers/component.html +25 -0
- package/bookshop-hugo-templates/helpers/component_key.html +11 -0
- package/bookshop-hugo-templates/helpers/partial.html +25 -0
- package/bookshop-hugo-templates/helpers/partial_key.html +9 -0
- package/full-hugo-renderer/build.sh +34 -0
- package/full-hugo-renderer/go.mod +87 -0
- package/{hugo-renderer → full-hugo-renderer}/go.sum +204 -12
- package/full-hugo-renderer/hugo_renderer.wasm +0 -0
- package/full-hugo-renderer/hugo_renderer.wasm.gz +0 -0
- package/full-hugo-renderer/main.go +215 -0
- package/{hugo-renderer → full-hugo-renderer}/wasm_exec.js +6 -2
- package/lib/builder.js +2 -2
- package/lib/engine.js +109 -42
- package/lib/hugoIdentifierParser.js +5 -0
- package/lib/translateTextTemplate.js +3 -0
- package/lib/translateTextTemplate.test.js +22 -16
- package/package.json +4 -4
- package/.nyc_output/processinfo/e4df4511-7e66-4fa6-84ed-6bd96e3027fe.json +0 -1
- package/hugo-renderer/build.sh +0 -66
- package/hugo-renderer/deps/bookshop_modified_deps.go +0 -6
- package/hugo-renderer/go.mod +0 -19
- package/hugo-renderer/helpers/bookshop_modified_content.go +0 -98
- package/hugo-renderer/helpers/bookshop_modified_general.go +0 -33
- package/hugo-renderer/helpers/emoji.go +0 -96
- package/hugo-renderer/hugo_renderer.wasm +0 -0
- package/hugo-renderer/hugo_renderer.wasm.gz +0 -0
- package/hugo-renderer/main.go +0 -42
- package/hugo-renderer/tpl/bookshop_engine/bookshop_func_importer.go +0 -35
- package/hugo-renderer/tpl/bookshop_engine/bookshop_render.go +0 -64
- package/hugo-renderer/tpl/bookshop_library/bookshop_components.go +0 -129
- package/hugo-renderer/tpl/bookshop_library/bookshop_data.go +0 -53
- package/hugo-renderer/tpl/cast/cast.go +0 -63
- package/hugo-renderer/tpl/cast/init.go +0 -57
- package/hugo-renderer/tpl/collections/append.go +0 -37
- package/hugo-renderer/tpl/collections/apply.go +0 -131
- package/hugo-renderer/tpl/collections/collections.go +0 -768
- package/hugo-renderer/tpl/collections/complement.go +0 -55
- package/hugo-renderer/tpl/collections/index.go +0 -133
- package/hugo-renderer/tpl/collections/init.go +0 -214
- package/hugo-renderer/tpl/collections/merge.go +0 -126
- package/hugo-renderer/tpl/collections/reflect_helpers.go +0 -216
- package/hugo-renderer/tpl/collections/sort.go +0 -183
- package/hugo-renderer/tpl/collections/symdiff.go +0 -68
- package/hugo-renderer/tpl/collections/where.go +0 -517
- package/hugo-renderer/tpl/compare/compare.go +0 -324
- package/hugo-renderer/tpl/compare/init.go +0 -85
- package/hugo-renderer/tpl/crypto/crypto.go +0 -109
- package/hugo-renderer/tpl/crypto/init.go +0 -65
- package/hugo-renderer/tpl/debug/debug.go +0 -40
- package/hugo-renderer/tpl/debug/init.go +0 -45
- package/hugo-renderer/tpl/encoding/encoding.go +0 -90
- package/hugo-renderer/tpl/encoding/init.go +0 -59
- package/hugo-renderer/tpl/fmt/fmt.go +0 -66
- package/hugo-renderer/tpl/fmt/init.go +0 -77
- package/hugo-renderer/tpl/inflect/inflect.go +0 -79
- package/hugo-renderer/tpl/inflect/init.go +0 -60
- package/hugo-renderer/tpl/internal/bookshop_modified_templatefuncsRegistry.go +0 -88
- package/hugo-renderer/tpl/math/init.go +0 -134
- package/hugo-renderer/tpl/math/math.go +0 -164
- package/hugo-renderer/tpl/math/round.go +0 -61
- package/hugo-renderer/tpl/partials/init.go +0 -55
- package/hugo-renderer/tpl/partials/partials.go +0 -88
- package/hugo-renderer/tpl/path/init.go +0 -60
- package/hugo-renderer/tpl/path/path.go +0 -159
- package/hugo-renderer/tpl/reflect/init.go +0 -51
- package/hugo-renderer/tpl/reflect/reflect.go +0 -36
- package/hugo-renderer/tpl/safe/init.go +0 -80
- package/hugo-renderer/tpl/safe/safe.go +0 -72
- package/hugo-renderer/tpl/site/bookshop_site.go +0 -67
- package/hugo-renderer/tpl/site/init.go +0 -41
- package/hugo-renderer/tpl/strings/init.go +0 -229
- package/hugo-renderer/tpl/strings/regexp.go +0 -125
- package/hugo-renderer/tpl/strings/strings.go +0 -500
- package/hugo-renderer/tpl/strings/truncate.go +0 -157
- package/hugo-renderer/tpl/transform/bookshop_unmarshal.go +0 -39
- package/hugo-renderer/tpl/transform/init.go +0 -113
- package/hugo-renderer/tpl/transform/transform.go +0 -116
- package/hugo-renderer/update-from-hugo.sh +0 -19
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":"
|
|
1
|
+
{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","pid":5472,"argv":["/opt/hostedtoolcache/node/16.18.1/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":1670194397574,"ppid":5432,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/0f70a16f-6a79-48c7-8b16-3b4665e247b2.json","externalId":"","uuid":"0f70a16f-6a79-48c7-8b16-3b4665e247b2","files":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":null,"pid":5432,"argv":["/opt/hostedtoolcache/node/16.18.1/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":1670194396754,"ppid":5421,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/6285d5fa-be3d-49e4-8f2f-82157d95dcd8.json","externalId":"","uuid":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","files":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":"
|
|
1
|
+
{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","pid":5465,"argv":["/opt/hostedtoolcache/node/16.18.1/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":1670194397530,"ppid":5432,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/8b5e1314-6e86-4197-a3ae-3c40e4c2f39e.json","externalId":"","uuid":"8b5e1314-6e86-4197-a3ae-3c40e4c2f39e","files":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":"
|
|
1
|
+
{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","pid":5449,"argv":["/opt/hostedtoolcache/node/16.18.1/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":1670194397196,"ppid":5432,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/c5490eb0-70c0-468f-a43f-e58c75dd34c8.json","externalId":"","uuid":"c5490eb0-70c0-468f-a43f-e58c75dd34c8","files":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"parent":"
|
|
1
|
+
{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","pid":5443,"argv":["/opt/hostedtoolcache/node/16.18.1/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":1670194397189,"ppid":5432,"coverageFilename":"/home/runner/work/bookshop/bookshop/javascript-modules/engines/hugo-engine/.nyc_output/ee1a9bec-d318-4aea-af93-7269debcf6df.json","externalId":"","uuid":"ee1a9bec-d318-4aea-af93-7269debcf6df","files":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"processes":{"
|
|
1
|
+
{"processes":{"0f70a16f-6a79-48c7-8b16-3b4665e247b2":{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","children":[]},"6285d5fa-be3d-49e4-8f2f-82157d95dcd8":{"parent":null,"children":["0f70a16f-6a79-48c7-8b16-3b4665e247b2","8b5e1314-6e86-4197-a3ae-3c40e4c2f39e","c5490eb0-70c0-468f-a43f-e58c75dd34c8","ee1a9bec-d318-4aea-af93-7269debcf6df"]},"8b5e1314-6e86-4197-a3ae-3c40e4c2f39e":{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","children":[]},"c5490eb0-70c0-468f-a43f-e58c75dd34c8":{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","children":[]},"ee1a9bec-d318-4aea-af93-7269debcf6df":{"parent":"6285d5fa-be3d-49e4-8f2f-82157d95dcd8","children":[]}},"files":{},"externalIds":{}}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Renders a Bookshop component
|
|
3
|
+
|
|
4
|
+
Expects a slice:
|
|
5
|
+
[
|
|
6
|
+
<string>, # Component name
|
|
7
|
+
<_> # Component props
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
Or a struct:
|
|
11
|
+
{
|
|
12
|
+
_bookshop_name: <string>, # Component name
|
|
13
|
+
..., # Component props
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Or a <string>: # Component name
|
|
17
|
+
*/}}
|
|
18
|
+
|
|
19
|
+
{{- $component_name := false -}}
|
|
20
|
+
{{- $component_props := false -}}
|
|
21
|
+
|
|
22
|
+
{{- if reflect.IsSlice . -}}
|
|
23
|
+
{{- if eq (len .) 2 -}}
|
|
24
|
+
{{- if eq (printf "%T" (index . 0)) "string" -}}
|
|
25
|
+
{{- $component_name = index . 0 -}}
|
|
26
|
+
{{- $component_props = index . 1 -}}
|
|
27
|
+
{{- else -}}
|
|
28
|
+
{{- $err := printf "Expected the first argument to be a string of the component name. Received %+v" (index . 0) -}}
|
|
29
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
30
|
+
{{- end -}}
|
|
31
|
+
{{- else -}}
|
|
32
|
+
{{- $err := printf "Expected a slice of length 2, was given %d" (len .) -}}
|
|
33
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
34
|
+
{{- end -}}
|
|
35
|
+
{{- else if reflect.IsMap . -}}
|
|
36
|
+
{{- if isset . "_bookshop_name" -}}
|
|
37
|
+
{{- $component_name = ._bookshop_name -}}
|
|
38
|
+
{{- $component_props = . -}}
|
|
39
|
+
{{- else -}}
|
|
40
|
+
{{- $err := printf "Expected the provided map to contain a _bookshop_name key. Was given %+v" . -}}
|
|
41
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
42
|
+
{{- end -}}
|
|
43
|
+
{{- else if eq (printf "%T" .) "string" -}}
|
|
44
|
+
{{- $component_name = . -}}
|
|
45
|
+
{{- $component_props = true -}}
|
|
46
|
+
{{- else if . -}}
|
|
47
|
+
{{- $err := printf "Expected a map, slice, or string. Was given the %T: %+v" . . -}}
|
|
48
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
49
|
+
{{- else -}}
|
|
50
|
+
{{- $err := printf "Expected a map, slice, or string. Was provided with no arguments" -}}
|
|
51
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
52
|
+
{{- end -}}
|
|
53
|
+
|
|
54
|
+
{{- if and $component_name $component_props -}}
|
|
55
|
+
{{- partial "_bookshop/helpers/component" (slice $component_name $component_props) -}}
|
|
56
|
+
{{- end -}}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Binds the next bookshop component to a given front matter data source
|
|
3
|
+
|
|
4
|
+
Expects one argument, a string to use as the data binding in CloudCannon
|
|
5
|
+
*/}}
|
|
6
|
+
|
|
7
|
+
{{- (printf `<!--bookshop-live meta(version: "3.3.3" baseurl: "%s" copyright: "%s" title: "%s")-->` site.BaseURL site.Copyright site.Title) | safeHTML }}
|
|
8
|
+
{{ $is_string := eq "string" (printf "%T" .) -}}
|
|
9
|
+
|
|
10
|
+
{{- if $is_string -}}
|
|
11
|
+
{{ (printf "<!--bookshop-live name(__bookshop__subsequent) params(.: %s)-->" .) | safeHTML }}
|
|
12
|
+
{{- else -}}
|
|
13
|
+
{{- $err := slice
|
|
14
|
+
(printf "bookshop_bindings expected a string but received \"%s\"" .)
|
|
15
|
+
" The `bookshop_bindings` partial should be passed a string"
|
|
16
|
+
" representation of the arguments to the component."
|
|
17
|
+
" Example usage:"
|
|
18
|
+
" ┌─"
|
|
19
|
+
" │ {{ partial \"bookshop_bindings\" `.Params.content_blocks` }}"
|
|
20
|
+
` │ {{ partial "bookshop_partial" (slice "page" .Params.content_blocks) }}`
|
|
21
|
+
" ├─"
|
|
22
|
+
" │ {{ partial \"bookshop_bindings\" `(dict \"content_html\" .Params.note_html \"type\" \"note\")` }}"
|
|
23
|
+
` │ {{ partial "bookshop" (slice "content" (dict "content_html" .Params.note_html "type" "note")) }}`
|
|
24
|
+
" └─"
|
|
25
|
+
" NB: The bookshop_bindings partial is only required in site layouts."
|
|
26
|
+
" It is not needed within Bookshop components."
|
|
27
|
+
-}}
|
|
28
|
+
{{- partial "_bookshop/errors/err" (delimit $err "\n") -}}
|
|
29
|
+
{{- end -}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Scaffolds the local or hosted Bookshop component browser
|
|
3
|
+
*/}}
|
|
4
|
+
|
|
5
|
+
{{- $port := 30775 -}}
|
|
6
|
+
{{- if . -}}
|
|
7
|
+
{{- if eq "int" (printf "%T" .) -}}
|
|
8
|
+
{{- $port = . -}}
|
|
9
|
+
{{- else -}}
|
|
10
|
+
{{- $err := slice
|
|
11
|
+
"bookshop_component_browser expected either no argument, or an integer for the local port number used when running @bookshop/browser."
|
|
12
|
+
(printf " Received: \"%s\"" .)
|
|
13
|
+
" "
|
|
14
|
+
" Example usage:"
|
|
15
|
+
" ┌─"
|
|
16
|
+
" │ {{ partial \"bookshop_component_browser\" }}"
|
|
17
|
+
" ├─"
|
|
18
|
+
" │ {{ partial \"bookshop_component_browser\" 30775 }}"
|
|
19
|
+
" └─"
|
|
20
|
+
-}}
|
|
21
|
+
{{- partial "_bookshop/errors/err" (delimit $err "\n") -}}
|
|
22
|
+
{{- end -}}
|
|
23
|
+
{{ end }}
|
|
24
|
+
|
|
25
|
+
<div data-bookshop-browser=""></div>
|
|
26
|
+
<script src="http://localhost:{{ $port }}/bookshop.js"></script>
|
|
27
|
+
<script>
|
|
28
|
+
window.bookshopBrowser = new window.BookshopBrowser({globals: []});
|
|
29
|
+
window.bookshopBrowser.render();
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Renders a Bookshop partial
|
|
3
|
+
|
|
4
|
+
Expects a slice:
|
|
5
|
+
[
|
|
6
|
+
<string>, # Partial name
|
|
7
|
+
<_> # Partial props
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
Or a <string>: # Component name
|
|
11
|
+
*/}}
|
|
12
|
+
|
|
13
|
+
{{- $partial_name := false -}}
|
|
14
|
+
{{- $partial_props := false -}}
|
|
15
|
+
|
|
16
|
+
{{- if reflect.IsSlice . -}}
|
|
17
|
+
{{- if eq (len .) 2 -}}
|
|
18
|
+
{{- if eq (printf "%T" (index . 0)) "string" -}}
|
|
19
|
+
{{- $partial_name = index . 0 -}}
|
|
20
|
+
{{- $partial_props = index . 1 -}}
|
|
21
|
+
{{- else -}}
|
|
22
|
+
{{- $err := printf "Expected the first argument to be a string of the partial name. Received %+v" (index . 0) -}}
|
|
23
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
24
|
+
{{- end -}}
|
|
25
|
+
{{- else -}}
|
|
26
|
+
{{- $err := printf "Expected a slice of length 2, was given %d" (len .) -}}
|
|
27
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
28
|
+
{{- end -}}
|
|
29
|
+
{{- else if eq (printf "%T" .) "string" -}}
|
|
30
|
+
{{- $partial_name = . -}}
|
|
31
|
+
{{- $partial_props = true -}}
|
|
32
|
+
{{- else if . -}}
|
|
33
|
+
{{- $err := printf "bookshop_partial tag expected a slice or string. Was given the %T: %+v" . . -}}
|
|
34
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
35
|
+
{{- else -}}
|
|
36
|
+
{{- $err := printf "bookshop_partial tag expected a slice or string. Was provided with no arguments" -}}
|
|
37
|
+
{{- partial "_bookshop/errors/bad_bookshop_tag" $err -}}
|
|
38
|
+
{{- end -}}
|
|
39
|
+
|
|
40
|
+
{{- if and $partial_name $partial_props -}}
|
|
41
|
+
{{- partial "_bookshop/helpers/partial" (slice $partial_name $partial_props) -}}
|
|
42
|
+
{{- end -}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Returns a slice of all Bookshop SCSS resources
|
|
3
|
+
*/}}
|
|
4
|
+
|
|
5
|
+
{{ $components := resources.Match "bookshop/components/**.scss" }}
|
|
6
|
+
{{ $shared := resources.Match "bookshop/shared/styles/**.scss" }}
|
|
7
|
+
{{ $bookshop_scss := $shared | append $components }}
|
|
8
|
+
|
|
9
|
+
{{ return $bookshop_scss }}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Prints examples of correct usage of the bookshop tag options
|
|
3
|
+
|
|
4
|
+
Expects a String containing a helpful error message.
|
|
5
|
+
*/}}
|
|
6
|
+
|
|
7
|
+
{{- $err := slice
|
|
8
|
+
.
|
|
9
|
+
" The following Bookshop tag formats are valid:"
|
|
10
|
+
""
|
|
11
|
+
" ► Render a \"button\" component with data:"
|
|
12
|
+
" ┌─"
|
|
13
|
+
" │ {{ partial \"bookshop\" (slice \"button\" (dict \"text\" .button.text)) }}"
|
|
14
|
+
" ├─"
|
|
15
|
+
" │ {{ with (dict \"text\" .button.text) }}"
|
|
16
|
+
" │ {{ partial \"bookshop\" (slice \"button\" .) }}"
|
|
17
|
+
" │ {{ end }}"
|
|
18
|
+
" └─"
|
|
19
|
+
""
|
|
20
|
+
" ► Render a component from a struct, where the struct contains a _bookshop_name key:"
|
|
21
|
+
" ┌─"
|
|
22
|
+
" │ {{ partial \"bookshop\" (dict \"_bookshop_name\" \"button\" \"text\" .button.text) }}"
|
|
23
|
+
" ├─"
|
|
24
|
+
" │ {{ partial \"bookshop\" .Params.component_structure }}"
|
|
25
|
+
" └─"
|
|
26
|
+
""
|
|
27
|
+
" ► Render a \"logo\" component with no data:"
|
|
28
|
+
" ┌─"
|
|
29
|
+
" │ {{ partial \"bookshop\" \"logo\" }}"
|
|
30
|
+
" └─"
|
|
31
|
+
""
|
|
32
|
+
" ► Render a \"tag\" partial with data:"
|
|
33
|
+
" ┌─"
|
|
34
|
+
" │ {{ partial \"bookshop_partial\" (slice \"tag\" (dict \"message\" \"Hello World\")) }}"
|
|
35
|
+
" └─"
|
|
36
|
+
" "
|
|
37
|
+
-}}
|
|
38
|
+
{{- partial "_bookshop/errors/err" (delimit $err "\n") -}}
|
|
39
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Renders a single Bookshop component,
|
|
3
|
+
wrapping in in a live editing context tag.
|
|
4
|
+
|
|
5
|
+
Expects a slice:
|
|
6
|
+
[
|
|
7
|
+
<string>, # Component name
|
|
8
|
+
<_> # Component props
|
|
9
|
+
]
|
|
10
|
+
*/}}
|
|
11
|
+
|
|
12
|
+
{{- $component_name := index . 0 -}}
|
|
13
|
+
{{- $component_props := index . 1 -}}
|
|
14
|
+
{{- $component_path := partial "_bookshop/helpers/component_key" $component_name -}}
|
|
15
|
+
|
|
16
|
+
{{- if templates.Exists ( printf "partials/%s" $component_path ) -}}
|
|
17
|
+
|
|
18
|
+
{{/* Suppress comments when live editing {{ (printf "<!--bookshop-live name(%s)-->" $component_name) | safeHTML }} */}}
|
|
19
|
+
{{- partial $component_path $component_props -}}
|
|
20
|
+
{{/* Suppress comments when live editing {{ "<!--bookshop-live end-->" | safeHTML }} */}}
|
|
21
|
+
|
|
22
|
+
{{- else -}}
|
|
23
|
+
{{- $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) -}}
|
|
25
|
+
{{- end -}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Converts a bare Bookshop component key to a Bookshop path
|
|
3
|
+
i.e. "a/b" --> "bookshop/components/a/b/b.hugo.html"
|
|
4
|
+
|
|
5
|
+
Expects a String.
|
|
6
|
+
*/}}
|
|
7
|
+
|
|
8
|
+
{{ $component_fragments := split . "/" }}
|
|
9
|
+
{{ $component_fragments = append (last 1 $component_fragments) $component_fragments }}
|
|
10
|
+
{{ $component_path := (printf "bookshop/components/%s.hugo.html" (delimit $component_fragments "/")) }}
|
|
11
|
+
{{ return $component_path }}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{{/*
|
|
2
|
+
Renders a single Bookshop partial,
|
|
3
|
+
wrapping in in a live editing context tag.
|
|
4
|
+
|
|
5
|
+
Expects a slice:
|
|
6
|
+
[
|
|
7
|
+
<string>, # Partial name
|
|
8
|
+
<_> # Partial props
|
|
9
|
+
]
|
|
10
|
+
*/}}
|
|
11
|
+
|
|
12
|
+
{{- $partial_name := index . 0 -}}
|
|
13
|
+
{{- $partial_props := index . 1 -}}
|
|
14
|
+
{{- $partial_path := partial "_bookshop/helpers/partial_key" $partial_name -}}
|
|
15
|
+
|
|
16
|
+
{{- if templates.Exists ( printf "partials/%s" $partial_path ) -}}
|
|
17
|
+
|
|
18
|
+
{{/* Suppress comments when live editing {{ (printf "<!--bookshop-live name(%s)-->" $partial_name) | safeHTML }} */}}
|
|
19
|
+
{{- partial $partial_path $partial_props -}}
|
|
20
|
+
{{/* Suppress comments when live editing {{ "<!--bookshop-live end-->" | safeHTML }} */}}
|
|
21
|
+
|
|
22
|
+
{{- else -}}
|
|
23
|
+
{{- $file_loc := slicestr $partial_path 9 -}}
|
|
24
|
+
{{- partial "_bookshop/errors/err" (printf "Partial \"%s\" does not exist.\n Create this partial by placing a file in your bookshop at %s" $partial_name $file_loc) -}}
|
|
25
|
+
{{- end -}}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
TMPFILENAME="hugo_renderer_$(date +%s).wasm"
|
|
4
|
+
OUTPUTFILENAME="hugo_renderer.wasm"
|
|
5
|
+
|
|
6
|
+
# Clean
|
|
7
|
+
rm -f $OUTPUTFILENAME
|
|
8
|
+
if [ -f $OUTPUTFILENAME ]; then
|
|
9
|
+
echo "ERROR: previous $OUTPUTFILENAME still in directory"
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
rm -f $OUTPUTFILENAME.gz
|
|
13
|
+
if [ -f $OUTPUTFILENAME.gz ]; then
|
|
14
|
+
echo "ERROR: previous $OUTPUTFILENAME.gz still in directory"
|
|
15
|
+
exit 1
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# Build temp module (For Windows use `$Env:GOOS = "js"; $Env:GOARCH = "wasm"` )
|
|
19
|
+
GOOS=js GOARCH=wasm go build -tags nodeploy -o $TMPFILENAME
|
|
20
|
+
printf "Built Hugo WASM via $TMPFILENAME : "
|
|
21
|
+
ls -lh $TMPFILENAME | awk '{print $5}'
|
|
22
|
+
|
|
23
|
+
# Link module
|
|
24
|
+
mv $TMPFILENAME $OUTPUTFILENAME
|
|
25
|
+
if [ ! -f $OUTPUTFILENAME ]; then
|
|
26
|
+
echo "ERROR: hugo_renderer.wasm not complete"
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
printf "Hugo WASM available at $OUTPUTFILENAME : "
|
|
30
|
+
ls -lh $OUTPUTFILENAME | awk '{print $5}'
|
|
31
|
+
|
|
32
|
+
gzip --keep $OUTPUTFILENAME
|
|
33
|
+
printf "Compressed Hugo WASM available at $OUTPUTFILENAME.gz : "
|
|
34
|
+
ls -lh $OUTPUTFILENAME.gz | awk '{print $5}'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module hugo-renderer
|
|
2
|
+
|
|
3
|
+
go 1.17
|
|
4
|
+
|
|
5
|
+
require (
|
|
6
|
+
github.com/gohugoio/hugo v0.107.0
|
|
7
|
+
github.com/spf13/afero v1.9.3
|
|
8
|
+
// Pin to an older version of overlayfs that Hugo is currently tied to
|
|
9
|
+
github.com/bep/overlayfs v0.6.0 // should be (v0.6.0)
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
require (
|
|
13
|
+
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 // indirect
|
|
14
|
+
github.com/BurntSushi/toml v1.2.1 // indirect
|
|
15
|
+
github.com/PuerkitoBio/purell v1.2.0 // indirect
|
|
16
|
+
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
|
|
17
|
+
github.com/alecthomas/chroma v0.10.0 // indirect
|
|
18
|
+
github.com/alecthomas/chroma/v2 v2.4.0 // indirect
|
|
19
|
+
github.com/armon/go-radix v1.0.0 // indirect
|
|
20
|
+
github.com/bep/clock v0.4.0 // indirect
|
|
21
|
+
github.com/bep/debounce v1.2.1 // indirect
|
|
22
|
+
github.com/bep/gitmap v1.3.0 // indirect
|
|
23
|
+
github.com/bep/goat v0.5.0 // indirect
|
|
24
|
+
github.com/bep/godartsass v0.14.0 // indirect
|
|
25
|
+
github.com/bep/golibsass v1.1.0 // indirect
|
|
26
|
+
github.com/bep/gowebp v0.2.0 // indirect
|
|
27
|
+
github.com/bep/tmc v0.5.1 // indirect
|
|
28
|
+
github.com/clbanning/mxj/v2 v2.5.7 // indirect
|
|
29
|
+
github.com/cli/safeexec v1.0.0 // indirect
|
|
30
|
+
github.com/disintegration/gift v1.2.1 // indirect
|
|
31
|
+
github.com/dlclark/regexp2 v1.7.0 // indirect
|
|
32
|
+
github.com/evanw/esbuild v0.15.16 // indirect
|
|
33
|
+
github.com/frankban/quicktest v1.14.4 // indirect
|
|
34
|
+
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
|
35
|
+
github.com/getkin/kin-openapi v0.110.0 // indirect
|
|
36
|
+
github.com/ghodss/yaml v1.0.0 // indirect
|
|
37
|
+
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
|
38
|
+
github.com/go-openapi/swag v0.22.3 // indirect
|
|
39
|
+
github.com/gobuffalo/flect v0.3.0 // indirect
|
|
40
|
+
github.com/gobwas/glob v0.2.3 // indirect
|
|
41
|
+
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20210430103248-4c28c89f8013 // indirect
|
|
42
|
+
github.com/gohugoio/locales v0.14.0 // indirect
|
|
43
|
+
github.com/gohugoio/localescompressed v1.0.1 // indirect
|
|
44
|
+
github.com/google/go-cmp v0.5.9 // indirect
|
|
45
|
+
github.com/hairyhenderson/go-codeowners v0.2.3-0.20201026200250-cdc7c0759690 // indirect
|
|
46
|
+
github.com/invopop/yaml v0.2.0 // indirect
|
|
47
|
+
github.com/jdkato/prose v1.2.1 // indirect
|
|
48
|
+
github.com/josharian/intern v1.0.0 // indirect
|
|
49
|
+
github.com/kr/pretty v0.3.1 // indirect
|
|
50
|
+
github.com/kr/text v0.2.0 // indirect
|
|
51
|
+
github.com/kyokomi/emoji/v2 v2.2.10 // indirect
|
|
52
|
+
github.com/mailru/easyjson v0.7.7 // indirect
|
|
53
|
+
github.com/marekm4/color-extractor v1.2.0 // indirect
|
|
54
|
+
github.com/mattn/go-isatty v0.0.16 // indirect
|
|
55
|
+
github.com/mattn/go-runewidth v0.0.14 // indirect
|
|
56
|
+
github.com/miekg/mmark v1.3.6 // indirect
|
|
57
|
+
github.com/mitchellh/hashstructure v1.1.0 // indirect
|
|
58
|
+
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
|
59
|
+
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
|
60
|
+
github.com/muesli/smartcrop v0.3.0 // indirect
|
|
61
|
+
github.com/niklasfasching/go-org v1.6.5 // indirect
|
|
62
|
+
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
|
63
|
+
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
|
64
|
+
github.com/pkg/errors v0.9.1 // indirect
|
|
65
|
+
github.com/rivo/uniseg v0.4.3 // indirect
|
|
66
|
+
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
|
67
|
+
github.com/russross/blackfriday v1.6.0 // indirect
|
|
68
|
+
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd // indirect
|
|
69
|
+
github.com/sanity-io/litter v1.5.5 // indirect
|
|
70
|
+
github.com/spf13/cast v1.5.0 // indirect
|
|
71
|
+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
|
72
|
+
github.com/spf13/pflag v1.0.5 // indirect
|
|
73
|
+
github.com/tdewolff/minify/v2 v2.12.4 // indirect
|
|
74
|
+
github.com/tdewolff/parse/v2 v2.6.4 // indirect
|
|
75
|
+
github.com/yuin/goldmark v1.5.3 // indirect
|
|
76
|
+
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594 // indirect
|
|
77
|
+
go.uber.org/atomic v1.10.0 // indirect
|
|
78
|
+
golang.org/x/image v0.1.0 // indirect
|
|
79
|
+
golang.org/x/net v0.2.0 // indirect
|
|
80
|
+
golang.org/x/sync v0.1.0 // indirect
|
|
81
|
+
golang.org/x/sys v0.2.0 // indirect
|
|
82
|
+
golang.org/x/text v0.4.0 // indirect
|
|
83
|
+
golang.org/x/tools v0.3.0 // indirect
|
|
84
|
+
google.golang.org/protobuf v1.28.1 // indirect
|
|
85
|
+
gopkg.in/yaml.v2 v2.4.0 // indirect
|
|
86
|
+
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
87
|
+
)
|