Hello,
I am attempting to access a page resource (a .csv file), through a shortcode (table_csv.html), which is itself called in a .md page resource (section-3.md) for the page (index.md).
The shortcode works when I call it directly in index.md, but not when I call it in the page resource section-3.md.
Any hack existing for calling a page resource from another markdown page resource within the same page?
File structure:
/contents/en/module/module-3/
- index.md
- mycsv.csv
- section-1.md
- section-2.md
- section-3.md
layouts/shortcodes/
-table_csv.html
{{ $csv := .Page.Resources.GetMatch "**.csv" }}
{{ $sep := "," }}
{{ $dataFile := getCSV $sep $csv.Permalink }}
<!-- your table building logic here -->
<table>
<thead>
<tr>
<th colspan='2'>
{{ $dataFile }}
</th>
</tr>
</thead>
</table>
layouts/modules/list.html
Copying below the part of the code used to display the .md page resources in the index.md :
<!--Include .Content from the resource pages named section-*.md -->
{{ $sections := .Resources.Match "section-*.md" }}
{{ range $sections }}
{{ $sectionClass := .Params.styling.sectionClass | default " "}}
{{ $containerClass := .Params.styling.containerClass | default " "}}
{{ $rowClass := .Params.styling.rowClass | default " "}}
<section class="{{ $sectionClass }}">
<div class="container {{ $containerClass }}">
<div class="row {{ $rowClass }}">
{{ .Content }}
</div>
</div>
</div>
</div>
</section>
{{ end }}
<!-- End of Include .Content from the resource pages named section-*.md -->
Whenever I try to include the shortcode in a .md page resource, I get the nil pointer error, meaning the getMatch does not manage to search the file in the right place:
execute of template failed: template: shortcodes/table_csv.html:4:32: executing "shortcodes/table_csv.html" at <$csv.Permalink>: nil pointer evaluating resource.Resource.Permalink