mirror of
https://github.com/gcushen/hugo-academic.git
synced 2025-07-26 19:15:16 +02:00
feat(shortcode): support Hugo v0.123 deprecation of GetCSV
Resolves following Hugo issue: INFO deprecated: data.GetCSV was deprecated in Hugo v0.123.0 and will be removed in a future release. use resources.Get or resources.GetRemote with transform.Unmarshal.
This commit is contained in:
parent
cee6e1e3e1
commit
07fe0da177
2 changed files with 24 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
{{/* Table Shortcode for Hugo Blox Builder. */}}
|
||||
{{/* Load a CSV table from page dir falling back back to remote URL */}}
|
||||
{{/* Load a CSV table from page dir falling back to remote URL */}}
|
||||
{{/* Defaults to expecting a comma-separated CSV with a header row. */}}
|
||||
|
||||
{{/*
|
||||
|
@ -23,17 +23,17 @@
|
|||
{{ $caption := .Get "caption" }}
|
||||
|
||||
{{ $is_remote := strings.HasPrefix $src "http" }}
|
||||
{{ if not $is_remote }}
|
||||
{{ $src = path.Join "content" $.Page.File.Dir $src }}
|
||||
{{ end }}
|
||||
{{ $rows := getCSV $delimiter $src }}
|
||||
{{ $rows := transform.Unmarshal (dict "delimiter" $delimiter) (.Page.Resources.Get $src).Content }}
|
||||
|
||||
<table class="table">
|
||||
{{ if $useHeaderRow }}
|
||||
{{ $headerRow := index $rows 0 }}
|
||||
{{ $rows = after 1 $rows }}
|
||||
<tr> {{ range $headerRow }} <th>{{ . | markdownify | emojify }}</th> {{ end }} </tr>
|
||||
<thead>
|
||||
<tr> {{ range $headerRow }} <th>{{ . | markdownify | emojify }}</th> {{ end }} </tr>
|
||||
</thead>
|
||||
{{ end }}
|
||||
<tbody>
|
||||
{{ range $rows }}
|
||||
<tr>
|
||||
{{ range . }}
|
||||
|
@ -45,6 +45,7 @@
|
|||
{{ end }}
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
{{ if $caption }}
|
||||
<caption>{{ $caption | markdownify | emojify }}</caption>
|
||||
{{ end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue