🚧🏗️👷🏾Note: This site is under construction. Expect a lot of broken links and layouts. Have feedback? Email me at gandiyafarai@gmail.com

HomeThe BikeshedComponents

ass-ref.html

Published: Updated:

Updates

  • Changed the code to allow for robust linking so you can directly reference something in the /assets/ directory.

I use this to reference assets on the site. You shouldn’t have to use this since the image and link render hooks do this for you, there are cases when you have to do this, like referencing site-hosted videos referenced through the <video> element.

Note: The name is somewhat intentional.

Source Code

{{- $path := strings.TrimPrefix "./" (.Get 0) }} {{- $path := strings.TrimPrefix "/assets" (.Get 0) }} {{- with or (.Page.Resources.GetMatch $path) (resources.Get $path) -}} {{ .Permalink }} {{- else -}} {{- errorf "%s called in %s does not exist. Add it" (.Get 0) .Page.File.Filename -}} {{- end -}}