Skip to content

Commit

Permalink
Changelog + Update hugo guide
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Mar 9, 2023
1 parent 1117ffa commit 8368c72
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 196 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@

## Unreleased

### New Hugo renderer

The main aspect of this release is a new and improved Hugo renderer when live editing on CloudCannon. Alongside being more reliable, this unlocks many templating functions that were previously unavailable, such as:

* `newScratch`
* `absURL`
* `highlight`
* `humanize`

Additionally, functions that would previously cause a full error (such as `resources.Get`) will now return `nil`, and as such can be handled gracefully inside a component.

Looking forward, this release also paves the path for supporting site actions like `site.GetPage` in the visual editor, as well as using custom non-Bookshop Hugo partials in the visual editor.

As with all releases, your repository can be upgraded to the latest Bookshop by running:
```
npx @bookshop/up@latest
```

### Other changes
* Hugo WebAssembly files are now preloaded in CloudCannon, so loading the visual editor should be significantly faster
* Improved data binding support for Hugo template files, and generally fixed many issues with complex templating
* Reduced noise in the developer console when live editing Hugo Bookshop sites

## v3.3.3 (December 2, 2022)

* Added a `markdownify` filter to Eleventy Bookshop
Expand Down
198 changes: 3 additions & 195 deletions guides/hugo.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2013,204 +2013,12 @@ Bookshop's Eleventy live editing is built on top of the liquidjs package. As suc
endif::Eleventy[]

ifdef::hugo[]
Bookshop's Hugo live editing is built on top of the core Go text/template package. As such, not all Hugo features are supported within Bookshop components. Generally, functions that interact with Hugo or the site as a whole are unavailable. The following tables describe the features and functions currently supported in live-edited Bookshop components.

NOTE: Work is underway to expand support for many of the functions below. Open a GitHub issue if there is a specific function you need for your workflow.
Bookshop's Hugo editing is based upon a subset of Hugo running in the browser. As such, not all Hugo features will be available within Bookshop components.

++++
<details><summary>Bookshop Hugo Support Matrix</summary>
++++

[cols="1,1"]
|===
|Hugo Feature |Supported in Bookshop

|link:https://gohugo.io/templates/partials/#returning-a-value-from-a-partial[Partial return values]
|❌

|link:https://gohugo.io/functions/scratch/[.Scratch and newScratch]
|❌
|===

For unsupported functions, see <<Rendering Different Content When Live Editing>>

[cols="1,1"]
|===
|Template Function |Supported in Bookshop

|templates.*
|❌
|os.*
|❌
|urls.*
|❌
|lang / i18n
|❌
|hugo
|❌
|apply
|❌
|anchorize
|❌
|absURL / absLangURL
|❌
|humanize
|❌
|now
|❌
|Image Filters
|❌
|partialCached
|❌
|getenv
|❌
|fileExists / readDir / readFile
|❌
|ref / relref
|❌
|relURL / relLangURL
|❌
|site.BaseURL / site.Title / site.Copyright
|✅
|Other site.* functions
|❌
|highlight
|ℹ️ Will pass through the input string unchanged (i.e. it won't work, but it won't error)
|markdownify
|ℹ️ Uses a different markdown implementation. Output isn't guaranteed to match Hugo 1:1
|strings.*
|✅
|reflect.*
|✅
|plainify
|✅
|emojify
|✅
|htmlEscape/htmlUnescape
|✅
|merge
|✅
|symdiff
|✅
|complement
|✅
|append
|✅
|group
|✅
|hmac
|✅
|transform.Unmarshal
|✅
|errorf and warnf
|✅
|float
|✅
|cond
|✅
|ge/gt/le/lt/ne
|✅
|after
|✅
|base64
|✅
|chomp
|✅
|countrunes
|✅
|countwords
|✅
|default
|✅
|delimit
|✅
|dict
|✅
|echoParam
|✅
|eq
|✅
|findRE
|✅
|first
|✅
|hasPrefix
|✅
|in
|✅
|index
|✅
|int
|✅
|intersect
|✅
|isset
|✅
|jsonify
|✅
|last
|✅
|len
|✅
|lower
|✅
|Math
|✅
|md5
|✅
|path.*
|✅
|pluralize
|✅
|print
|✅
|printf
|✅
|println
|✅
|querify
|✅
|range
|✅
|replace
|✅
|replaceRE
|✅

|===
As a general rule: Functions that access files directly (such as `resources.Get`), or access other parts of the site (such as `site.GetPage`), will not return anything useful in the visual editor.

[cols="1,1"]
|===
|Page Function |Supported in Bookshop

|.AddDate
|❌
|.Format
|❌
|.Get
|❌
|.GetPage
|❌
|.HasMenuCurrent
|❌
|.IsMenuCurrent
|❌
|.Param
|❌
|.Render
|❌
|.RenderString
|❌
|.Scratch
|❌
|.Unix
|❌

|===

++++
</details>
++++
If you're encountering an unsupported function, such as finding that `resources.Get` returns `nil`, see <<Rendering Different Content When Live Editing>>

endif::hugo[]

Expand Down
3 changes: 2 additions & 1 deletion javascript-modules/engines/hugo-engine/lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ export class Engine {
try {
return JSON.parse(output);
} catch (e) {
console.warn(`Error evaluating \`${str}\` in the Hugo engine`, output);
logger?.log?.(`Error evaluating \`${str}\` in the Hugo engine`);
logger?.log?.(output);
return null;
}
}
Expand Down

0 comments on commit 8368c72

Please sign in to comment.