Skip to content

Commit 0d6b0c8

Browse files
committed
fix: move the Hugo live environment flag to site.Params
1 parent c97c5c0 commit 0d6b0c8

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

guides/eleventy.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ You can render special content in the live editing environment by checking the B
18901890

18911891
ifdef::hugo[]
18921892
```go
1893-
{{ if isset . "env_bookshop_live" }}
1893+
{{ if site.Params.env_bookshop_live }}
18941894
<p>I am being edited live!</p>
18951895
<h1>Fallback {{ .my_page }} title</h1>
18961896
{{ else }}

guides/hugo.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ You can render special content in the live editing environment by checking the B
18901890

18911891
ifdef::hugo[]
18921892
```go
1893-
{{ if isset . "env_bookshop_live" }}
1893+
{{ if site.Params.env_bookshop_live }}
18941894
<p>I am being edited live!</p>
18951895
<h1>Fallback {{ .my_page }} title</h1>
18961896
{{ else }}

guides/jekyll.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ You can render special content in the live editing environment by checking the B
18901890

18911891
ifdef::hugo[]
18921892
```go
1893-
{{ if isset . "env_bookshop_live" }}
1893+
{{ if site.Params.env_bookshop_live }}
18941894
<p>I am being edited live!</p>
18951895
<h1>Fallback {{ .my_page }} title</h1>
18961896
{{ else }}

javascript-modules/engines/hugo-engine/hugo-renderer/tpl/site/bookshop_site.go

+8
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,11 @@ func (ns *Namespace) BaseURL() (interface{}, error) {
5757

5858
return meta["baseurl"], nil
5959
}
60+
61+
// Pending mock out of the params function
62+
func (ns *Namespace) Params() (map[string]interface{}, error) {
63+
params := make(map[string]interface{})
64+
params["env_bookshop_live"] = true
65+
66+
return params, nil
67+
}

javascript-modules/integration-tests/features/eleventy/live_editing/eleventy_bookshop_live_granules.feature

+10
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ Feature: Eleventy Bookshop CloudCannon Live Editing Granular Steps
101101
{% else %}
102102
<h1>DEAD? {{ title }}</h1>
103103
{% endif %}
104+
{% bookshop "nested" title: title %}
105+
"""
106+
Given a component-lib/components/nested/nested.eleventy.liquid file containing:
107+
"""
108+
{% if env_bookshop_live %}
109+
<h2>LIVE! {{ title }}</h2>
110+
{% else %}
111+
<h2>DEAD? {{ title }}</h2>
112+
{% endif %}
104113
"""
105114
Given 🌐 I have loaded my site in CloudCannon
106115
When 🌐 CloudCannon pushes new yaml:
@@ -111,3 +120,4 @@ Feature: Eleventy Bookshop CloudCannon Live Editing Granular Steps
111120
Then 🌐 There should be no errors
112121
* 🌐 There should be no logs
113122
* 🌐 The selector h1 should contain "LIVE! 🫑"
123+
* 🌐 The selector h2 should contain "LIVE! 🫑"

javascript-modules/integration-tests/features/hugo/live_editing/hugo_bookshop_live_granules.feature

+11-1
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,20 @@ Feature: Hugo Bookshop CloudCannon Live Editing Granular Steps
107107
Scenario: Bookshop sets a flag when live editing
108108
Given a component-lib/components/single/single.hugo.html file containing:
109109
"""
110-
{{ if isset . "env_bookshop_live" }}
110+
{{ if site.Params.env_bookshop_live }}
111111
<h1>LIVE! {{ .title }}</h1>
112112
{{ else }}
113113
<h1>DEAD? {{ .title }}</h1>
114114
{{ end }}
115+
{{ partial "bookshop" (slice "nested" (dict "title" .title)) }}
116+
"""
117+
Given a component-lib/components/nested/nested.hugo.html file containing:
118+
"""
119+
{{ if site.Params.env_bookshop_live }}
120+
<h2>LIVE! {{ .title }}</h2>
121+
{{ else }}
122+
<h2>DEAD? {{ .title }}</h2>
123+
{{ end }}
115124
"""
116125
Given 🌐 I have loaded my site in CloudCannon
117126
When 🌐 CloudCannon pushes new yaml:
@@ -122,3 +131,4 @@ Feature: Hugo Bookshop CloudCannon Live Editing Granular Steps
122131
Then 🌐 There should be no errors
123132
* 🌐 There should be no logs
124133
* 🌐 The selector h1 should contain "LIVE! 🫑"
134+
* 🌐 The selector h2 should contain "LIVE! 🫑"

javascript-modules/integration-tests/features/jekyll/live_editing/jekyll_bookshop_live_granules.feature

+10
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ Feature: Jekyll Bookshop CloudCannon Live Editing Granular Steps
100100
{% else %}
101101
<h1>DEAD? {{ include.title }}</h1>
102102
{% endif %}
103+
{% bookshop nested title=include.title %}
104+
"""
105+
Given a component-lib/components/nested/nested.jekyll.html file containing:
106+
"""
107+
{% if env_bookshop_live %}
108+
<h2>LIVE! {{ include.title }}</h2>
109+
{% else %}
110+
<h2>DEAD? {{ include.title }}</h2>
111+
{% endif %}
103112
"""
104113
Given 🌐 I have loaded my site in CloudCannon
105114
When 🌐 CloudCannon pushes new yaml:
@@ -110,3 +119,4 @@ Feature: Jekyll Bookshop CloudCannon Live Editing Granular Steps
110119
Then 🌐 There should be no errors
111120
* 🌐 There should be no logs
112121
* 🌐 The selector h1 should contain "LIVE! 🫑"
122+
* 🌐 The selector h2 should contain "LIVE! 🫑"

0 commit comments

Comments
 (0)