Hi, I have started to create my first theme and have been struggling with leaf bundles for a couple of weeks now: time to register and post a question.
What I would like to accomplish is the following:
- I receive an HTML file which contains a document. Along with it comes a PDF file with the same content.
- I want to display the HTML file and have a link to download the corresponding PDF file.
What I have done is the following:
-
I have a
single.html
file that contains{{ .Content }}
. -
My directory structure looks like this:
- content
- kb
- testkb
- index.md
- myfiles
- source.html
- source.pdf
- testkb
- kb
- content
-
The file index.md contains the resources like so:
title: ‘Test KB article’
author: Marc
date: ‘2019-11-27’
draft: false
resources:- src: myfiles/source.html
name: SourceHTML
title: Source HTML - src: myfiles/source.pdf
name: SourcePDF
title Source PDF
{{< showfile >}}
- src: myfiles/source.html
-
The shortcode
showfile
has contained a number of things in order to try to make this work; not yet touching on providing the link to download the PDF file. For example:
<embed src="{{ (.Resources.Match “**”).Content }}" width=“100%” height=“100%”>
or
<embed src="{{ (.Resources.Match “SourceHTML”).Content }}" width=“100%” height=“100%”>
or
<embed src="{{ (.Resources.Match “source.html”).Content }}" width=“100%” height=“100%”>
or
<embed src="{{ (.Resources.Match “myfiles/source.html”).Content }}" width=“100%” height=“100%”>
or
{{ with .Page.Resources.GetMatch “SourceHTML” }}
{{ end }}
or
{{ range .Page.Resources.Match “*” }}
{{ end }}
I have read the Hugo Page Bundle documentation numerous times, as well as the Hugo Page Resources documentation.
I must be missing something. Any help to get me on the right track is much appreciated.
Thank you.
Marc.