vmware-tanzu-labs / educates-training-platform

A platform for hosting interactive workshop environments in Kubernetes, or on top of a local container runtime.
https://docs.educates.dev
Apache License 2.0
63 stars 15 forks source link

Add data variable for workshop content base url. #375

Open GrahamDumpleton opened 1 month ago

GrahamDumpleton commented 1 month ago

Is your feature request related to a problem? Please describe.

Because of borked behaviour of Hugo when used at a base URL with sub path, the figure short code when used needs to explicitly include the /workshop/content/ prefix in the src attribute when referring to static files placed in the workshop/static directory of the workshop files. This requirement isn't documented, also doesn't seem right to have a static path prefix encoded everywhere.

Describe the solution you'd like

Document how to use images when using the Hugo renderer, and provide a data variable that can be used in place of the static prefix.

For example, if an image file was placed in the workshop/static/images directory, then instead of needing to say:

{{< figure src="/workshop/content/images/image.png" >}}

one could perhaps use:

{{< figure src="{{< param workshop_baseurl >}}/images/image.png" >}}

This presumes nesting of params like this works in Hugo as there are tricks needed with quoting to actually have that work, so will need testing.

Describe alternatives you've considered

The alternative is to use relative paths. For example:

{{< figure src="../images/image.png" >}}

Additional information

Note that this only applies to image files placed in the workshop/static directory. If Hugo page bundles are used then the image can be placed in the page bundle directory and can be reference with a relative path instead.